/*
有三个for循环,让三个循环开三个线程同时运行。
其中一个main线程,再创建两个线程。
*/
class ThreadTest
{
public static void main(String[] args)
{
new Thread()//匿名内部类
{
public void run()
{
for(int x=0; x<100; x++)
{
//System.out.println(Thread.currentThread().getName()+"...."+x);
System.out.println("x="+x);
}
}
}.start();
for(int y=0; y<100; y++)
{
//System.out.println(Thread.currentThread().getName()+"...."+y);
System.out.println("y= "+y);
}
Runnable r = new Runnable()
{
public void run()
{
for(int z=0; z<100; z++)
{
//System.out.println(Thread.currentThread().getName()+"...."+z);
System.out.println("z= "+z);
}
}
};
new Thread(r).start();
}
}