简单的线程优先级的问题

在实现java编程思想的小例子的时候发现运行结果不一样,书上的结果是先执行完优先级最高的才执行优先级低的,但是我的却没有先把优先级最高的线程执行完
代码如下:
package concurrency;

import java.util.concurrent.*;

public class SimplePriorities implements Runnable{

private int countDown = 5;
private int priority;
@SuppressWarnings("unused")
private volatile double d;

public SimplePriorities(int priority) {
    this.priority = priority;
}

public String toString(){
    return Thread.currentThread() + ": " + countDown;
}

@Override
public void run(){ 
    Thread.currentThread().setPriority(priority);
    while(true){
        for(int i = 1; i < 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 < 5; i++) {
        exec.execute(new SimplePriorities(Thread.MIN_PRIORITY));
    }
    exec.execute(new SimplePriorities(Thread.MAX_PRIORITY));
    exec.shutdown();

}

}
运行结果如下
Thread[pool-1-thread-6,10,main]: 5
Thread[pool-1-thread-6,10,main]: 4
Thread[pool-1-thread-4,1,main]: 5
Thread[pool-1-thread-3,1,main]: 5
Thread[pool-1-thread-1,1,main]: 5
Thread[pool-1-thread-2,1,main]: 5
Thread[pool-1-thread-6,10,main]: 3
Thread[pool-1-thread-5,1,main]: 5
Thread[pool-1-thread-6,10,main]: 2
Thread[pool-1-thread-6,10,main]: 1
Thread[pool-1-thread-4,1,main]: 4
Thread[pool-1-thread-1,1,main]: 4
Thread[pool-1-thread-3,1,main]: 4
Thread[pool-1-thread-2,1,main]: 4
Thread[pool-1-thread-5,1,main]: 4
Thread[pool-1-thread-4,1,main]: 3
Thread[pool-1-thread-2,1,main]: 3
Thread[pool-1-thread-1,1,main]: 3
Thread[pool-1-thread-3,1,main]: 3
Thread[pool-1-thread-5,1,main]: 3
Thread[pool-1-thread-3,1,main]: 2
Thread[pool-1-thread-2,1,main]: 2
Thread[pool-1-thread-4,1,main]: 2
Thread[pool-1-thread-1,1,main]: 2
Thread[pool-1-thread-5,1,main]: 2
Thread[pool-1-thread-3,1,main]: 1
Thread[pool-1-thread-4,1,main]: 1
Thread[pool-1-thread-2,1,main]: 1
Thread[pool-1-thread-1,1,main]: 1
Thread[pool-1-thread-5,1,main]: 1
求大神赐教!

线程优先级高的并不一定会先执行完,优先级的唯一作用就是(两个线程同时)在等待的时候,会优先把资源分配给优先级高的线程(产生优先级高的线程先执行的错觉),如果你的(优先级低)线程已经开始执行了,那么后面优先级高的线程并不会抢夺资源优先执行,而是等待系统分配资源,由于在主函数中是顺序执行的,你把优先级低的线程放在前面(更早开始执行),那它的执行顺序就会在高优先级的前面,优先级一般在高并发中才能体现出来,一两个线程没什么意义

Java通过Executors提供四种线程池,分别为:
newCachedThreadPool创建一个可缓存线程池,如果线程池长度超过处理需要,可灵活回收空闲线程,若无可回收,则新建线程。
newFixedThreadPool 创建一个定长线程池,可控制线程最大并发数,超出的线程会在队列中等待。
newScheduledThreadPool 创建一个定长线程池,支持定时及周期性任务执行。
newSingleThreadExecutor 创建一个单线程化的线程池,它只会用唯一的工作线程来执行任务,保证所有任务按照指定顺序(FIFO, LIFO, 优先级)执行。
你使用的是创建一个可缓存线程池,这种线程池的执行时没有顺序的,是并行的,你可以看下这篇http://www.mamicode.com/info-detail-1085507.html