Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

wait and notify are said to be communication mechanism in threads but then why are they not declared in Thread class and are declared in Object class instead?

share|improve this question

put on hold as off-topic by durron597, GlenH7, MichaelT, Snowman, Ixrec Apr 21 at 22:29

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Stack Overflow search shows 169 results: stackoverflow.com/search?q=Why+notify+and+wait+are+in+object I't also FAQ'd at Code Ranch: Why are wait(), notify(), and notifyAll() in the Object class? –  gnat Jan 9 '13 at 11:07
5  
I'm voting to close this question as off-topic because it should be on SO, but it's too old to migrate and it would be closed as a duplicate there anyway of this question: stackoverflow.com/questions/17840397/… –  durron597 Apr 21 at 17:08

1 Answer 1

because each object is a monitor

and so you can have multiple sets of waiting threads, and having to manage waiting threads yourself requires extra bookkeeping (now handled by the VM) and is prone to deadlock and other thread related bugs

share|improve this answer
    
no because the implementers of the JVM are smart enough to avoid them –  ratchet freak Jan 9 '13 at 11:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.