2017/7/31 created
* * JDK 10 priority and operating system mapping is not good, so only recommended max_priority,norm_priority,min_priority * Three priority/public class Simplepriorities Impl
Ements Runnable {private int countdown=5;
Prevent the compiler from optimizing the variable D private volatile double D;
private int priority;
public simplepriorities (int priority) {this.priority=priority;
Public String toString () {return thread.currentthread () + ":" +countdown; The priority of the @Override public void Run () {//thread should be set within run because the thread only has a valid Thread.CurrentThread () priority set after running. SE
Tpriority (priority); while (true) {for (int i = 0; I < 10000 i++) {//When the divisor is 0 o'clock, the program does not throw an exception because 0 in double is not really 0 or 0.0 and
is a very long//may be 0.000000000001 or other, so a positive number divided by 0.0 results will be very big d+= (MATH.PI+MATH.E)/(double) I;
if (i%1000==0) {Thread.yield ();
} System.out.println (this);
if (--countdown==0) {return; }} public static void Main (string[] args) {Executorservice Exec=executors.newcache
Dthreadpool ();
for (int i = 0; i < 5; i++) {Exec.execute (new simplepriorities (thread.min_priority));
} exec.execute (New Simplepriorities (thread.max_priority));
Exec.shutdown ();
}
}