67,513
社区成员
发帖
与我相关
我的任务
分享
class sync_thread
{
public static void main (String argv[])
{
Runnable r=new name_test();
Thread t1=new Thread(r,"t1");
Thread t2=new Thread(r,"t2");
t1.setPriority(Thread.MAX_PRIORITY);
t2.setPriority(Thread.MIN_PRIORITY);
t2.start();
t1.start();
}
}
/*11.4
****
*/
class name_test implements Runnable {
public void run()
{
for(int i=0;i<10;i++)
{
/*
if(i==5 && Thread.currentThread().getName().equals("t1"))
{
Thread.yield();
}
*/
System.out.println("Name:"+Thread.currentThread().getName()+" i: "+i);
}
}
}