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

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