Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread wait() state.  RSS feed

 
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: 23283
125
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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!