• Post Reply Bookmark Topic Watch Topic
  • New Topic

Different Thread Types

 
Duncan Godfrey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I�m having a little problem with Threads which I hope some can help me with, sorry if it�s a repeat question.
I have a class which spawns two different thread objects, one to act on a queue of hosts that should respond quickly and the second to act on a separate queue of slow hosts. There is a number of each kind of thread.
The problem I�m having is trying to use the wait() and notify() methods on two different types of thread object in the same class. If the fast queue is empty I want the fast threads to wait and then be notified if a host is added, the same for the slow queue. I�m just not sure how to separate them.
Thanks in advance,
Duncan
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A number of threads working items out of a queue sounds like classic thread pooling. Is your logic similar to the Jakarta Commons Pool using a blocking queue? I'd think one queue instance for "fast" queue and another for "slow" queue would keep things straight. Threads in the fast pool would wait on the fast queue and threads in the slow pool would wait on the slow queue. Each queue's notify will wake up only the threads in the correct pool.
How does that sound?
 
Duncan Godfrey
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply., that sounds like what Im looking for. Thanks for pointing me in the right direction, I will wade into the documentation!
Duncan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!