首页 > 编程语言 > 详细

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

时间:2020-07-22 23:28:24      阅读:51      评论:0      收藏:0      [点我收藏+]
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)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!