ThreadPriority线程优先级
作者:
勇者与王者 | 来源:发表于
2019-10-10 19:07 被阅读0次package multiThread;
/**
*
* @author qz:
* @version 创建时间:2019年10月10日 上午10:26:55
*
*/
public class ThreadPriority {
public static void main(String[] args) {
// TODO Auto-generated method stub
final Hero gareen = new Hero();
gareen.name = "盖伦";
gareen.hp = 6160;
gareen.damage = 1;
final Hero teemo = new Hero();
teemo.name = "提莫";
teemo.hp = 300;
teemo.damage = 1;
final Hero bh = new Hero();
bh.name = "赏金猎人";
bh.hp= 5000;
bh.damage = 1;
final Hero leesin = new Hero();
leesin.name = "李青";
leesin.hp = 300;
leesin.damage = 1;
Thread t1 = new Thread() {
public void run() {
while (!teemo.isDead()) {
gareen.attackHero(teemo);
}
}
};
Thread t2 = new Thread() {
public void run() {
while (!leesin.isDead()) {
bh.attackHero(leesin);
}
}
};
t1.setPriority(Thread.MAX_PRIORITY);
t2.setPriority(Thread.MIN_PRIORITY);
System.out.println(Thread.MAX_PRIORITY);
System.out.println(Thread.MIN_PRIORITY);
t1.start();
t2.start();
}
}
本文标题:ThreadPriority线程优先级
本文链接:https://www.haomeiwen.com/subject/ldwapctx.html
网友评论