线程优先级

package state;

public class TestPoriority {
    public static void main(String[] args) {

        MyPoriority myPoriority = new MyPoriority();
        Thread  t1 = new Thread(myPoriority);
        Thread  t2 = new Thread(myPoriority);
        Thread  t3 = new Thread(myPoriority);
        Thread  t4 = new Thread(myPoriority);
        
        t1.start();
        t2.setPriority(1);
        t2.start();
        t3.setPriority(4);
        t3.start();
        t3.setPriority(Thread.MAX_PRIORITY);
        t4.start();
        System.out.println(Thread.currentThread().getName()+"---"+Thread.currentThread().getState());


    }
}
class MyPoriority implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"---"+Thread.currentThread().getState());
    }
}
posted @ 2023-03-10 23:03  北极有熊ovo  阅读(18)  评论(0)    收藏  举报