クラスjava.util.concurrent.ThreadPoolExecutor
の使用
ThreadPoolExecutorを使用するパッケージ
-
java.util.concurrentでのThreadPoolExecutorの使用
型ThreadPoolExecutorのパラメータを持つjava.util.concurrentのメソッド修飾子と型メソッド説明voidRejectedExecutionHandler.rejectedExecution(Runnable r, ThreadPoolExecutor executor) executeがタスクを受け入れることができない場合にThreadPoolExecutorによって呼び出される可能性のあるメソッドです。voidThreadPoolExecutor.AbortPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e) 常にRejectedExecutionExceptionをスローします。voidThreadPoolExecutor.CallerRunsPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e) executorがシャットダウンしていない場合に、呼出し側のスレッドでタスクrを実行します。シャットダウンしている場合、タスクは破棄されます。voidThreadPoolExecutor.DiscardOldestPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e) executorがシャットダウンしないかぎり、タスクがすぐに利用可能な場合にexecutorが実行するはずの次のタスクを取得して無視し、タスクrの実行を再度試みます。シャットダウンしている場合、タスクrは破棄されます。voidThreadPoolExecutor.DiscardPolicy.rejectedExecution(Runnable r, ThreadPoolExecutor e) 何も実行しません。これは、破棄するタスクrの効果を保持します。