私はスレッドを制御します。JVMでは、アプリケーションは並列に実行される複数のスレッドを使用することができます。
フィールド
- public static final int MIN_PRIORITY - スレッドに設定できる最低優先順位
- public static final int NORM_PRIORITY - スレッドに割り当てられるデフォルトの優先順位
- public static final int MAX_PRIORITY - スレッドに設定できる最高優先順位
メソッド
- sleep* - 現在実行中のスレッドを指定されたミリ秒数の間スリープ(一時的に停止)させる
例
現在実行中のスレッドを指定されたミリ秒数の間スリープ(一時的に停止)させます。
String str = "Hello World!!\nAre you enjoying Java?"; char[] chars = str.toCharArray(); for (char letter : chars) { System.out.print(letter); try { Thread.sleep(100); } catch (InterruptedException e) { System.out.println("error!"); } } System.out.println("");