Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread wait() state.

 
Jiafan Zhou
Ranch Hand
Posts: 193
Fedora Linux Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a thread invokes a wait() method and enters the wait state, does this thread still consumes the CPU cycle? (I think the answer is yes, need confirm this)

Thanks
 
Henry Wong
author
Sheriff
Posts: 22542
109
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jiafan Zhou wrote:If a thread invokes a wait() method and enters the wait state, does this thread still consumes the CPU cycle? (I think the answer is yes, need confirm this)

Thanks


It depends on the implemention -- but the answer is... it shouldn't. Some JVMs may spin for a short period, before giving up the time slice (based on history of the thread waiting on the lock).

Henry
 
This parrot is no more. It has ceased to be. Now it's a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!