-
ob.a++;
try{
Thread.sleep(1000);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
class C extends Thread
{
C()
{
start();
}
public void run()
{
for(int i=0;i<2;i++)
{
System.out.println("ValueC:"+ob.a);
ob.a++;
try{
Thread.sleep(1000);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}
B t1=new B();
C t2=new C();
}
}
">anybody can explain how it is going to work and why it works soclass A{ int a; A() { a=20; }}class Myth{public static void main(String S[]){final A ob=new A(); class B extends Thread { B() { start(); } public void run() { for(int i=0;i
-
-
-
-