Main Content

ThreadPool

Parallel pool of thread workers on the local machine

Since R2020a

Description

Use parpool to create a parallel pool of thread workers on your local machine. After you create the pool, parallel pool features, such as parfor or parfeval, run on the workers. With the ThreadPool object, you can interact with the parallel pool.

Creation

Create a parallel pool of thread workers on the local machine by using the parpool function.

pool = parpool('Threads')

Properties

expand all

This property is read-only.

Flag that indicates whether the thread pool is busy, specified as true or false. The pool is busy if there is outstanding work for the pool to complete.

This property is read-only.

Queue of FevalFuture objects to run on the thread pool, returned as a FevalQueue object. You can use this property to check the pending and running future variables of the parallel pool. To create future variables, use parfeval and parfevalOnAll. For more information on future variables, see Future.

Data Types: FevalQueue

Store of files accessible to both client and workers, specified as a FileStore object.

This property is read-only.

Number of thread workers comprising the parallel pool, specified as an integer. You can specify the number of thread workers during pool creation with parpool.

Store of data accessible to both client and workers, specified as a ValueStore object.

Object Functions

deleteShut down parallel pool
parfevalRun function on parallel pool worker
parfevalOnAllRun function asynchronously on all workers in parallel pool

Limitations

  • Pools created using parpool('Threads') and backgroundPool are both thread-based pools which utilize the same resources. It is possible that activity on one pool may block activity on the other and vice versa. Additionally, persistent data and random number generation stream state are shared in between these pools. For more information on controlling random number streams, see Control Random Number Streams on Workers.

  • Not all functionality is supported in a thread-based environment. For details on specific limitations, see Check Thread Supported Functions.

Version History

Introduced in R2020a