threads
10が常に同じクラスを実行していることを確認するソフトウェアを実装したいと思います。
たとえば、ランダムに一定の秒数が経過するとすべてthreads
が終了しますが、終了するとすぐに新しく作成されたthreads
.
利用可能なライブラリがあるかどうか知っていますか?
どうもありがとう、ヴラド
threads
10が常に同じクラスを実行していることを確認するソフトウェアを実装したいと思います。
たとえば、ランダムに一定の秒数が経過するとすべてthreads
が終了しますが、終了するとすぐに新しく作成されたthreads
.
利用可能なライブラリがあるかどうか知っていますか?
どうもありがとう、ヴラド
むしろ、スレッド プールを使用します。JavaExecutor
フレームワークが提供します。
ExecutorService executor = Executors.newFixedThreadPool(10);
ExecutorService executorPool = Executors.newFixedThreadPool(noOfThreads);
public static ExecutorService newFixedThreadPool(int nThreads)
Creates a thread pool that reuses a fixed set of threads operating off a
shared unbounded queue. If any thread terminates due to a failure during execution prior to shutdown, a new one will take its place if needed to execute subsequent tasks.
Parameters:
nThreads - the number of threads in the pool
Returns:
the newly created thread pool