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 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Calling methods on a waiting thread" Watch "Calling methods on a waiting thread" New topic

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

Joined: Jul 08, 2003
Posts: 24183

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
Why Thread isn't being notified in this case
how to release the lock??
Confirming notify()
difference between wait() and sleep()