What is the Thread.State of a thread after Thread.yield() ? Is it a Thread.State.WAITING? Thanks.
What is the Thread.State of a thread after Thread.yield() ? Is it a Thread.State.WAITING
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, the thread will still be in the
RUNNABLEstate. Note thatRUNNABLEsignifies that a thread is available to be run and may be either currently running or waiting its turn.Thread.STATEdoes not distinguish between a thread that is currently executing and a thread that is ready to run, they are bothRUNNABLE.A thread will only enter the
WAITINGstate when eitherwait(),join()orLockSupport.park()has been called.By calling
Thread.yield()method the currently running thread is voluntarily giving up its slice of CPU time. This thread then goes from running back into a ready state.