ThreadPriority线程优先级

2019-10-10  本文已影响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();
        
        
        
    }

}
上一篇 下一篇

猜你喜欢

热点阅读