1

threads10が常に同じクラスを実行していることを確認するソフトウェアを実装したいと思います。

たとえば、ランダムに一定の秒数が経過するとすべてthreadsが終了しますが、終了するとすぐに新しく作成されたthreads.

利用可能なライブラリがあるかどうか知っていますか?

どうもありがとう、ヴラド

4

2 に答える 2

5

むしろ、スレッド プールを使用します。JavaExecutorフレームワークが提供します。

ExecutorService executor = Executors.newFixedThreadPool(10);
于 2013-03-12T16:13:56.553 に答える
0
   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
于 2013-03-12T16:20:16.733 に答える