Thread pool with a varying amount of threads.

A new thread is spawned every time a task is submitted while all existing threads are busy.


@:value({ threadTimeout : 60 })new(maxThreadsCount:Int, threadTimeout:Float = 60)

Create a new thread pool with threadsCount threads.

If a worker thread does not receive a task for threadTimeout seconds it is terminated.


read onlyisShutdown:Bool

Indicates if shutdown method of this pool has been called.

read onlythreadsCount:Int


run(task:() ‑> Void):Void

Submit a task to run in a thread.

Throws an exception if the pool is shut down.


Initiates a shutdown. All previousely submitted tasks will be executed, but no new tasks will be accepted.

Multiple calls to this method have no effect.