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

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();
}
}
posted @ 2020-07-22 21:05  一块  阅读(831)  评论(0编辑  收藏  举报