This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A question on wait()." Watch "A question on wait()." New topic
Author

A question on wait().

Ruchika Kapoor
Greenhorn

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

Thanks,
Ruchika
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


Cheers!
RSR
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()


http://www.expertaya.com
Campbell Ritchie
Sheriff

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


Yes, it is a nice analogy.
 
 
subject: A question on wait().
 
Similar Threads
is wait() an instance method of Thread Class
Threads - Runnable vs. Extending Thread
Threads
Passed Part 2/3 with 100
Interview q