File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes A question on wait(). Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A question on wait()." Watch "A question on wait()." New topic

A question on wait().

Ruchika Kapoor

Joined: Oct 03, 2004
Posts: 22
Why do we have wait() in Object class rather than in Thread class.

rakesh sugirtharaj
Ranch Hand

Joined: Dec 16, 2007
Posts: 151
Imagine that you are standing in a crowd to meet a VIP one-on-one. Everyone is rushing in to meet him/her. Now who should say - "Hey!wait.. come in a queue" ?? You(i mean, one of the waiting people) or the VIP(or his/her bodyguards) ?? Similar case for object and threads. Many threads try to access the object and only the object says - wait or next(notify). Pretty good question actually

Dragan Stankovic
Ranch Hand

Joined: Oct 14, 2008
Posts: 33
I like your example. I'll use it for sure when asked to explain wait()
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46437
Originally posted by Dragan Stankovic:
I like your example.

Yes, it is a nice analogy.
I agree. Here's the link:
subject: A question on wait().
It's not a secret anymore!