code
-----
import java.lang.*;
class x extends Thread
{
public void run()
{
for(int i =0;i<4;i++) System.out.println("x");
}
}
class test extends Thread
{
public void run()
{
for(int i =0;i<4;i++) System.out.println("test");
}
public static void main(String args[])
{
x th1 = new x();
test th2 = new test();
th1.start();
th2.start();
}
}
output:
--------
>java test
x
x
x
x
test
test
test
test
why this code is not obeying concurrency?? i have created 2 threads
and called start()....but these two threads are doing sequential
opeartion !!( as you see the output...outputs are same for several
run).
where i am wrong? how can i achieve concurrency ??