File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A question on wait().

 
Ruchika Kapoor
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do we have wait() in Object class rather than in Thread class.

Thanks,
Ruchika
 
rakesh sugirtharaj
Ranch Hand
Posts: 151
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like your example. I'll use it for sure when asked to explain wait()
 
Campbell Ritchie
Sheriff
Pie
Posts: 47231
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dragan Stankovic:
I like your example.


Yes, it is a nice analogy.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic