影响这个问题的因素太多了。线程组、线程时序、jdk版本等等。总之,写程序不要依赖线程的执行顺序。这种东西是不能跨平台的

解决方案 »

  1.   

    我把你的
    a1.start();a2.start();a3.start();a4.start(); a5.start();
    a1.setPriority(1);a2.setPriority(7);a3.setPriority(8);a4.setPriority(9);a5.setPriority(6);颠倒一下:
    a1.setPriority(1);a2.setPriority(7);a3.setPriority(8);a4.setPriority(9);a5.setPriority(6);
    a1.start();a2.start();a3.start();a4.start(); a5.start();得到的结果是:222333444555111
      

  2.   

    setPrioritypublic final void setPriority(int newPriority)Changes the priority of this thread. First the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException. Otherwise, the priority of this thread is set to the smaller of the specified newPriority and the maximum permitted priority of the thread's thread group. 
    Parameters:
    newPriority - priority to set this thread to