本帖最后由 费破的可 于 2013-10-27 10:31 编辑
class Demo implements Runnable
{
public void run()
{
for(int x=0; x<50; x++)
{
System.out.println(Thread.currentThread().toString()+"....."+x);
Thread.yield();//暂停进程
}
}
}
class JoinDemo
{
public static void main(String[] args) throws Exception
{
Demo d = new Demo();
Thread t1 = new Thread(d);
Thread t2 = new Thread(d);
t1.start();
t2.start();
for(int x=0; x<500; x++)
{
System.out.println(Thread.currentThread()+"....."+x);
}
}
}
|