try putting Thread.yield() in each of your loops as in:
class x extends Thread
{
public void run()
{
for(int i =0;i<test.count;i++)
{
System.out.println("x");
Thread.yield();
}
}
}
class y extends Thread
{
public void run()
{
for(int i =0;i<test.count;i++)
{
System.out.println("y");
Thread.yield();
}
}
}
public class test
{
public static final int count = 4;
public static void main(String args[])
{
new x().start();
new y().start();
}
}
result:
x
x
y
x
y
x
y
y