aspose file tools*
The moose likes Threads and Synchronization and the fly likes java biginer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "java biginer" Watch "java biginer" New topic
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: 232

call notify() method from thread object which you are using at the time of wait() method call.


SCJP 6- 91%, IBM DB2, IBM RAD Certified
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
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