多线程,设置线程的优先级。

时间:2020-07-22 23:28:24   收藏:0   阅读:52
public class Demo06 {
public static void main(String[] args) {
Thread t1 = new Thread() {
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(getName() + "...AAAAAAAAAA");
}
}
};
Thread t2 = new Thread() {
public void run() {
for (int i = 0; i < 10; i++) {
System.out.println(getName() + "...BBBBBBBBBB");
}
}
};
t1.setPriority(Thread.MAX_PRIORITY); //设置线程最大优先级
t2.setPriority(Thread.MIN_PRIORITY); //设置线程最小优先级
t1.start();
t2.start();
}
}

原文:https://www.cnblogs.com/wangffeng293/p/13363137.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!