public class TestThreadPriority {
public static void main(String[] args) {
Thread t1 = new Thread(new SubThread("Thread_1"));
Thread t2 = new Thread(new SubThread("T_H_R_E_A_D_-_-_2"));
t1.setPriority(Thread.NORM_PRIORITY + 3);
t1.start();
t2.start();
}
}
class SubThread implements Runnable{
private String name;
SubThread(String str){
name = str;
}
public void run(){
Thread.currentThread().setName(name);
for(int i = 0; i < 1000; i++){
System.out.println(Thread.currentThread().getName() + ": " + i);
}
}
}
Toy Program——线程的优先级Priority
最新推荐文章于 2023-04-11 10:23:29 发布