クラスjava.util.concurrent.ThreadPoolExecutor
の使用
| パッケージ | 説明 |
|---|---|
| java.util.concurrent |
並行プログラミングでよく使用されるユーティリティ・クラスです。
|
-
java.util.concurrentでのThreadPoolExecutorの使用
java.util.concurrentでのThreadPoolExecutorのサブクラス 修飾子と型 クラス 説明 classScheduledThreadPoolExecutor指定された遅延時間後または定期的にコマンドを実行するようにスケジュールできる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の効果を保持します。