testmainpriority.java

来自「java 完全探索的随书源码」· Java 代码 · 共 31 行

JAVA
31
字号
public class TestMainPriority{  public static final int NUMBER_OF_THREADS = 5;  public static void main(String[] args)  {    SimpleThread[] threads = new SimpleThread[NUMBER_OF_THREADS];    for( int i = 0; i < NUMBER_OF_THREADS; i++ )    {      String name = "Thread: " + i;      SimpleThread newThread = new SimpleThread( name );      threads[i] = newThread;      // If this is the last thread, set it's priority to the maximum      // otherwise set the priority of the thread to the minimum      if ( i == NUMBER_OF_THREADS )      {        newThread.setPriority( Thread.MAX_PRIORITY );      }      else      {        newThread.setPriority( Thread.MIN_PRIORITY );      }    }    for ( int i = 0; i < NUMBER_OF_THREADS; i++ )    {      threads[i].start();    }  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?