Libraries anvil runtime ThreadPool

class ThreadPool
extends anvil.lang.object
ThreadPool is pool of re-usable threads. Re-use of threads is beneficial as the relative heavy-weight creation of thread can be avoided.

Constructor
ThreadPool()
ThreadPool(string name)
ThreadPool(string name, int maxthreads)
ThreadPool(string name, int maxthreads, int maxtasks)
Creates new thread pool.


Methods

int getMaxTasks()
Gets the maximum number of tasks. Sum of free, active and waiting tasks never exceeds this number.

int getMaxThreads()
Gets the maximum number of threads. No more that the given number of threads are created.

ThreadPool setMaxTasks(int maxtask)
Gets the maximum number of tasks. Sum of free, active and waiting tasks never exceeds this number.

ThreadPool setMaxThreads(int maxthreads)
Sets the maximum number of threads. No more that the given number of threads are created.

ThreadPool shutdown()
Shuts down this thread pool. All threads are closed but the pool remains usable after shutdown.

ThreadPool spawn(object callable, ..parameters)
Spawns a task. Task may not be immediately executed if all threads are currently in use.

int threads()
Gets the number of threads created.

int waiting()
Gets the number of tasks waiting to be executed.