Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wait() method question

 
ujjawal rohra
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Can anyone explian that the wait method is called on an instance of t or on an instance of Trd ??? I cant understand
 
Ankit Garg
Sheriff
Posts: 9510
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
t is not a class, its just a reference variable of Thread class. The wait method is called on the Instance of Trd class which you pass into the Thread class constructor. When you call the start method, Thread class calls the run method of your Trd class...
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explian that the wait method is called on an instance of t or on an instance of Trd ???

When the thread t encounters the call to wait() method it will stop (or wait for another thread to execute notify() or notifyAll() on the same object that is instance of the Trd class in this case) executing, you will see yourself if you run the code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic