aspose file tools
The moose likes Threads and Synchronization and the fly likes Thread pool: Notifier or Listener Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Thread pool: Notifier or Listener" Watch "Thread pool: Notifier or Listener" New topic
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Thread pool: Notifier or Listener
 
Similar Threads
Beginner: Threads vs. Runnables
How to know that all the threads in pool are done with execution ?
Proper Event Processing
Need Information about wait(),notiy(),notifyAll() in java
thread pool