public class TestPriopity {
public static void main(String[] args) {
Thread t1 = new Thread(new T1());
Thread t2 = new Thread(new T2());
t1.setPriority(Thread.NORM_PRIORITY + 3);//设置线程的优先级
t1.start();
t2.start();
}
}
class T1 implements Runnable {
@Override
public void run() {
for(int i=0;i<=1000;i++) {
System.out.println("oneThread.." + i);
}
}
}
class T2 implements Runnable {
@Override
public void run() {
for(int i=0;i<=1000;i++) {
System.out.println("twoThread--" + i);
}
}
}
java线程优先级的简单应用
最新推荐文章于 2023-08-23 08:49:52 发布