• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling methods on a waiting thread  RSS feed

 
Roy Mallard
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!