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


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