Answer Posted / rajashree
A thread pool is a collection of threads, which you
keep "alive" and use/reuse to process incoming "tasks".
When a new tasks arrives (a typical example is a request to
an HTTP server) you try to find a thread from the
collection, which is idle, and handle the task to it. If no
such thread exists you either wait for one to become
available or add a new thread to the pool (usually there is
an upper limit, though). After the thread has finished
processing the task, it is not terminated, only marked as
idle and ready to be reused for another task.
The main advantages of using a thread pool as opposed to
creating a new thread to handle each new task are:
1) By reusing threads you save the thread
creation/destruction overhead.
2) You have control over the maximum number of tasks that
are being processed in parallel (= number of threads in the
pool).
| Is This Answer Correct ? | 8 Yes | 14 No |
Post New Answer View All Answers
What is the difference between sleep and wait in java?
What is data movement?
Can It is possible to synchronize the constructor of a Java Class?
Is java ee a framework?
What are constants and how to create constants in java?
How do you insert a line break?
Can we convert list to set in java?
What is a boolean used for?
What is the use of :: in java?
What is module in project?
What is immutable state?
Which collections are thread safe in java?
Explain the importance of finalize() method.
What is scope & storage allocation of global and extern variables? Explain with an example
How will you invoke any external process in java?