标签:
2016-07-01
package com.java1995; public class MyRunnable1 implements Runnable{ @Override public void run() { // TODO Auto-generated method stub for(int i=0;i<100;i++){ System.out.print("+"); } } }
package com.java1995; public class MyRunnable2 implements Runnable{ @Override public void run() { // TODO Auto-generated method stub for(int i=0;i<100;i++) System.out.print("*"); } }
package com.java1995; public class Test { public static void main(String[] args) { MyRunnable1 r1=new MyRunnable1(); MyRunnable2 r2=new MyRunnable2(); Thread t1=new Thread(r1); Thread t2=new Thread(r2); System.out.println("t1的优先级:"+ t1.getPriority()); System.out.println("t2的优先级:"+t2.getPriority()); //给t1设置最高的优先级 t1.setPriority(Thread.MAX_PRIORITY); System.out.println("t1改变之后的优先级是:"+t1.getPriority()); //给t2设置最低的优先级 t2.setPriority(Thread.MIN_PRIORITY); System.out.println("t2改变之后的优先级是:"+t2.getPriority()); t1.start();//就绪状态 t2.start();//就绪状态 } }
标签:
原文地址:http://www.cnblogs.com/cenliang/p/5634267.html