| Author |
java biginer
|
ash sangy
Greenhorn
Joined: Jul 09, 2011
Posts: 6
|
|
hi
i have a doubt in core java multithreading i have to invoke waited threads (assume 10 threads are waiting state) how can we cal only one particular waiting thread using notify()?
|
 |
Thakur Sachin Singh
Ranch Hand
Joined: Jun 15, 2010
Posts: 209
|
|
|
call notify() method from thread object which you are using at the time of wait() method call.
|
my blog SCJP 6- 91%, IBM DB2, IBM RAD Certified
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
I don't think you can call a particular thread like that. If you call notify(), you call one thread, selected non-deterministically. If you call notifyAll() you can wake any because all threads are notified.
I think this question too difficult for "beginning" so I shall move it.
|
 |
Madhan Sundararajan Devaki
Ranch Hand
Joined: Mar 18, 2011
Posts: 312
|
|
|
Have volatile boolean variables for each Thread and set to true the one for the required Thread. Within the Thread check if its volatile variable is set to true, if so do the needful, if not go back to sleep. Call notifyAll().
|
S.D. MADHAN
Not many get the right opportunity !
|
 |
 |
|
|
subject: java biginer
|
|
|