| Author |
Thread pool: Notifier or Listener
|
Arup Kumar Kabi
Greenhorn
Joined: Jul 13, 2007
Posts: 3
|
|
I am trying to make a thread pool so the design goes like this A thread pool, will manage lot of activities of thread like how many threads are there in the pool, which is active, giving a thread handle to a task etc. but after the thread has finished the task That is where I have a dilemma I am not able to think whether to associate a notifier with the Thread in that case Thread itself communicates saying I'm done with the task or a Listener which would check which thread is done and which is active etc. and notify the thread pool both of them have their own complexity and I am not able to choose one any thoughts....
|
 |
Carey Evans
Ranch Hand
Joined: May 27, 2008
Posts: 225
|
|
|
You might want to have a look at how the ThreadPoolExecutor thread pool works in the standard Java library. It's been very carefully designed by smarter people than me.
|
 |
Nitesh Kant
Bartender
Joined: Feb 25, 2007
Posts: 1638
|
|
Although I totally agree with Carey's advice, I would still like to answer your question. Actually, in a threadpool it is far more easier if your thread runs continuously and polls a work queue for tasks. If you get into an entity that hands over work after choosing a relevant thread, you will be addressing an unnecessary issue.
|
apigee, a better way to API!
|
 |
Arup Kumar Kabi
Greenhorn
Joined: Jul 13, 2007
Posts: 3
|
|
|
Hey Nishant & Carey thanks a lot for the pointers.
|
 |
 |
|
|
subject: Thread pool: Notifier or Listener
|
|
|