title: Compiler ignore threads priorities
body: <p>I tried to compile the example from Thinking in Java by Bruce Eckel:</p>
  
  <pre><code>import java.util.concurrent.*;
  
  public class SimplePriorities implements Runnable {
    private int countDown = 5;
    private volatile double d; // No optimization
    private int priority;
    public SimplePriorities(int priority) {
      this.priority = priority;
    }
    public String toString() {
      return Thread.currentThread() + ": " + countDown;
    }
    public void run() {
      Thread.currentThread().setPriority(priority);
      while(true) {
        // An expensive, interruptable operation:
        for(int i = 1; i &lt; 100000; i++) {
          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.newCachedThreadPool();
      for(int i = 0; i &lt; 5; i++)
        exec.execute(
          new SimplePriorities(Thread.MIN_PRIORITY));
      exec.execute(
          new SimplePriorities(Thread.MAX_PRIORITY));
      exec.shutdown();
    }
  }
  </code></pre>
  
  <p>According to the book, the output has to look like:</p>
  
  <pre><code>Thread[pool-1-thread-6,10,main]: 5
  Thread[pool-1-thread-6,10,main]: 4
  Thread[pool-1-thread-6,10,main]: 3
  Thread[pool-1-thread-6,10,main]: 2
  Thread[pool-1-thread-6,10,main]: 1
  Thread[pool-1-thread-3,1,main]: 5
  Thread[pool-1-thread-2,1,main]: 5
  Thread[pool-1-thread-1,1,main]: 5
  ...
  </code></pre>
  
  <p>But in my case 6th thread doesn't execute its task at first and threads are disordered. Could you please explain me what's wrong? I just copied the source and didn't add any strings of code.</p>