package state;
public class TestPriority {
//主线程默认优先级
public static void main(String[] args) {
System.out.println(Thread.currentThread().getName()+"-->"+Thread.currentThread().getPriority());
MyPriority priority = new MyPriority();
Thread t1 = new Thread(priority);
Thread t2 = new Thread(priority);
Thread t3 = new Thread(priority);
Thread t4 = new Thread(priority);
t1.start();
t2.setPriority(10);
t2.start();
t3.setPriority(8);
t3.start();
t4.setPriority(7);
t4.start();
}
}
class MyPriority implements Runnable{
@Override
public void run() {
System.out.println(Thread.currentThread().getName()+"-->"+Thread.currentThread().getPriority());
}
}
javaSE之多线程之优先级
最新推荐文章于 2023-10-10 00:41:15 发布