多線程,設置線程的優先級。


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();
}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM