In the code below we are directly calling the
run() method.how is this possible?? i thought
we have to call the start() method in order
to call run()
please explain...
class a1 extends
Thread {
public static void main(
String args[])
{
a1 a =new a1();
Thread a11 = new Thread(a);
Thread a12 = new Thread(a);
a11.run();
a12.run();
}
int x=1,y=1;
synchronized void method1()
{
x =x+1;
y=y+1;
}
public void run()
{
for(int i =0 ; i<5;i++)
{
method1();
System.out.println(x+""+y);
}
}
}