Thread Pool

A thread pool is a queue of threads available to run a queue of tasks. Thread pools are used to improve performance when executing large numbers of asynchronous tasks by reducing per-task invocation overhead and provide a means of bounding and managing the resources consumed when executing a collection of tasks.

A thread pool is created with zero threads.

General

Property Required? Editable? Accepts SVars? Description
Core Pool Size N Y Y When a new task is submitted and fewer than Core Pool Size threads are running, a new thread is created to handle the request, even if other threads are idle. If there are greater than Core Pool Size but fewer than Max Pool Size threads running, a new thread is created only if no threads are idle. Must be greater than or equal to zero.

Default: 2. Two threads are used to service one request: one for receiving the request and one for receiving the response.

Max Pool Size N Y Y The maximum number of threads in the pool. Must be greater than zero and greater than or equal to Core Pool Size.

Default: 10.

Keep Alive Time (s) N Y Y The amount of time an idle thread remains in the pool before being reclaimed if the number of threads in pool is more than Core Pool Size.

Default: 30 Seconds.

Autostart Core Threads N N Y Indicate that Core Pool Size threads should be created and started when the thread pool is created. Normally core threads are created and started only when new tasks arrive.

Default: false.

Thread Pool Name Prefix N Y Y A string prepended to the name of each thread.

Default: <pool-poolnumber-thread-threadnumber>

Priority Y N Y The default priority of the threads in the pool.

Default: 5.

Rejection Policy Y N N The policy applied when no thread is available to run a task:
  • Abort - The task is aborted and an exception is thrown.
  • Blocking - The task is blocked until a thread from thread pool picks up this task.
  • Caller Runs - The task is run in the calling thread.

Default: Blocking.

Daemon N N Y Indicate whether the threads can be started as daemon or user.

Default: Unchecked.