Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Threads and Synchronization and the fly likes Which thread comes first from wait(). Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Which thread comes first from wait()." Watch "Which thread comes first from wait()." New topic
Author

Which thread comes first from wait().

sachin Dhanvijay
Greenhorn

Joined: May 14, 2001
Posts: 1
I want to know when we notify all threads from a wait() method which thread comes out first ...means it comes through priority or through ageing.
sachin.
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
It's random - there's no determining which will acquire the lock after notifyAll() is called.
ANAND RAMKUMAR
Greenhorn

Joined: Jan 01, 2001
Posts: 8
you cannot determine which thread comes out of the wait state and to seek the lock state of the object.ageing is not the concept there.
Peter Haggar
author
Ranch Hand

Joined: Jan 03, 2001
Posts: 106
One thing you can do to determine which thread runs after a notifyAll is implement the Specific Notification Pattern found here.
Peter Haggar
------------------
Senior Software Engineer, IBM
author of: Practical Java


Senior Software Engineer, IBM
author of: Practical Java
Ipsita Naravane
Greenhorn

Joined: Dec 27, 2000
Posts: 29
Wow! great information.
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which thread comes first from wait().
 
Similar Threads
Notify Thread by a JButton
KnB notify(), wait(), synchronized block
Threads and synchronization!!
Synchronization issue
Wait And Notify concept