How to notify specific thread??

From: bunallo (nmnm_at_alala.com)
Date: 02/25/05


Date: Fri, 25 Feb 2005 03:44:37 +0100

If I have x number of threads that is waiting and I only want to notify a
specific thread how do I do this?

The situation is that I have some threads that needs to wait until a
specific object is inserted into a Database (made as a hashtable). When that
object is inserted into the database only the thread that waited for this
specific object is supposed to be notified.

I have made a notifyAll () call and then a while loop that checks if there
is one of all the newly notified that inserted the object. Each time this
while loop is false the wait is invoked on the thread.

But I would like to be able to notify only the correct thread. Heard this
could be done by making each thread lock on a unique object, but I can't
seem to make any sense out of it.

Hope someone can give me some ideas!



Relevant Pages

  • Re: calling wait outside of loop
    ... and notify has been called prior to wait, ... what is the argument for calleding after the loop. ... Typically you may have multiple threads waiting, only one of which can proceed. ... Each thread will need to check the notify is for them. ...
    (comp.lang.java.programmer)
  • Re: spurious wakeup
    ... The while loop protects against spurious wakeups too. ... You can provide a function which takes the predicate as an object, ... >> is the classic pattern of waiting for a condition. ... You may safely notify in more cases than needed (degrading ...
    (comp.lang.cpp)
  • RE: inserting XML Document into Oracle database using a stored procedure
    ... You say it the database is not being called. ... inserting XML Document into Oracle database using a stored ... Please notify the sender of the ... This electronic message transmission is a PRIVATE communication which contains ...
    (perl.dbi.users)
  • Re: How to notify specific thread??
    ... > If I have x number of threads that is waiting and I only want to notify a ... > specific object is inserted into a Database. ... > while loop is false the wait is invoked on the thread. ... > But I would like to be able to notify only the correct thread. ...
    (comp.lang.java.help)
  • Re: How to notify specific thread??
    ... > while loop is false the wait is invoked on the thread. ... > But I would like to be able to notify only the correct thread. ... It is impossible to notify a specific thread that's waiting on a ... then you can split the monitor into several monitors. ...
    (comp.lang.java.help)