ThreadPool - Parallel pool of thread workers on the local machine - MATLAB (original) (raw)
Main Content
Parallel pool of thread workers on the local machine
Description
Use parpool
to create a parallel pool of thread workers on your local machine. After you create the pool, parallel pool features, such asparfor
or parfeval
, run on the workers. With theThreadPool
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') - Create a pool partition from an existing parallel pool using the partition function. (since R2025a)
Properties
This property is read-only.
Flag that indicates whether the thread pool is busy, returned astrue
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, useparfeval and parfevalOnAll. For more information on future variables, see Future.
Data Types: FevalQueue
Store of files accessible to both client and workers, returned as a FileStore object.
This property is read-only.
Number of thread workers comprising the parallel pool, returned 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, returned as a ValueStore object.
Since R2025a
This property is read-only.
Information about workers comprising the parallel pool, returned as an array ofparallel.Worker objects.
Object Functions
Composite | Create and access nondistributed variables on multiple workers from client |
---|---|
delete | Shut down parallel pool |
parfeval | Run function on parallel pool worker |
parfevalOnAll | Run function asynchronously on all workers in parallel pool |
partition | Partition parallel pool |
parforOptions | Options set for parfor |
spmd | Execute code in parallel on workers of 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
To identify the workers in a pool, use the Workers
property.