Home
»
tutorial
»
Thread pool in Java
June 27, 2021
Ravi Yasas
The Thread pool
Introduction
- Executor implementations use thread pools.
- The thread pool is a collection of worker threads that are ready to serve.
- Creating new threads and manage them uses a big amount of data.
- Worker threads in the thread pool will help to reduce this overhead of creating threads.
- Tasks are submitted to the pool via an internal queue called blocking queue.
- If there are more tasks than active threads, these tasks will be inserted into a blocking queue until a thread becomes available.
- A common type of thread pool is the fixed thread pool.
Fixed thread pool
- This has a specific number of running threads.
- If a thread stops, this will replace with a new thread.
- The main advantage of the fixed thread pool is it will limit the threads of an application.
- It won't let the application exceed the limit of threads that the application handles.
0 comments :
Post a Comment