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

Thread yield method  RSS feed

 
Rajiv Rai
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no guarantee that Thread.yield method
will put current thread into runnable state.

Is the above true?
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajiv Rai wrote:There is no guarantee that Thread.yield method
will put current thread into runnable state.

Is the above true?

Yes.

yield method simply 'conveys' thread scheduler that current thread is ready to give up the processor, and 'requests' that the thread may be moved out of running state to runnable state. However, thread scheduler is free to ignore this request.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!