当前位置:网站首页>thread priority

thread priority

2022-06-26 05:07:00 Light ink CGZ

/** * Observe the thread state  */
public class Allstate{
    
   public static viod main(String[] args){
    
   Thread t = new Thread(()->{
    
   		System.out.println("……");
   		})
   // Observation state 
   State state = t.getState();
   System.out.println(state);//NEW
	}
}

State of thread , Five states : Can pass state see .

Thread priority :
Range from 1 To 10
Thread.MIN_PRIORITY = 1
Thread.MAX_PRIORITY = 10
Thread.NORM_PRIORITY = 5
Use setPriority(int newPriority);
getPriority();
get , And setting priorities ;
Setting recommendations in start() Before calling .
Be careful : Priority knowledge means that the probability of scheduling is low . It is not absolutely first to call high priority first .

原网站

版权声明
本文为[Light ink CGZ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206260505080834.html