标签:current ++ open sys nbsp rgs ide alt class
优先级代表着抢资源的频率
所有线程默认优先级是5
yield()临时释放线程的执行权
1 class Demo implements Runnable 2 { 3 public void run() 4 { 5 for(int x = 0; x < 70; x++) 6 { 7 System.out.println(Thread.currentThread().toString()+"..."+x); 8 Thread.yield(); 9 } 10 } 11 } 12 13 class JoinDemo 14 { 15 public static void main(String[] args) throws Exception 16 { 17 Demo d = new Demo(); 18 Thread t1 = new Thread(d); 19 Thread t2 = new Thread(d); 20 t1.start(); 21 //t1.join(); 22 //t1.setPriority(Thread.MAX_PRIORITY); 23 t2.start(); 24 for(int x = 0; x < 70; x++) 25 { 26 //System.out.println("main..."+x); 27 } 28 System.out.println("over"); 29 } 30 }
标签:current ++ open sys nbsp rgs ide alt class
原文地址:http://www.cnblogs.com/hepengke/p/7071789.html