bunallo
2005-02-25 02:44:37 UTC
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!
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!