aspose file tools*
The moose likes Beginning Java and the fly likes Calling methods on a waiting thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling methods on a waiting thread" Watch "Calling methods on a waiting thread" New topic
Author

Calling methods on a waiting thread

Roy Mallard
Ranch Hand

Joined: Jul 14, 2005
Posts: 53
IF a thread is waiting on an object, and some other threads call the thread's methods, do the method calls get queued up and invoked when the thread is notified?


SCJP 1.4<br />SCJD
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24168
    
  30

Hi Roy,

Threads don't have methods; they invoke methods. A method always runs on the Thread that calls it -- although sometimes, the calling thread has to wait for the privilege.

If a Thread is waiting on an object, that actually has no effect at all on any other threads that call any of that same object's methods.


[Jess in Action][AskingGoodQuestions]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Calling methods on a waiting thread
 
Similar Threads
Confirming notify()
Yield()
Why Thread isn't being notified in this case
difference between wait() and sleep()
how to release the lock??