Aryan PrajapatKnowledge Contributor
Can you explain the Java thread lifecycle?
Can you explain the Java thread lifecycle?
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.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
A thread can be in any of the following states in Java. These are the states:
New: A new thread is always in the new state when it is first formed. The function hasn’t been run yet, thus it hasn’t started to execute for a thread in the new state.
Active: A thread switches from the new state to the active state when it calls the start() method. The runnable state and the running state are both contained within the active state.
Blocked or Waiting: A thread is either in the blocked state or the waiting state when it is inactive for a while (but not indefinitely).
Timed waiting: When we use the sleep () method on a particular thread, we are actually engaging in timed waiting. The thread enters the timed wait state using the sleep () function. The thread awakens when the allotted time has passed and resumes execution where it left off.
Termination: A thread that has been terminated means it is no longer active in the system. In other words, the thread is inactive and cannot be revived (made active again after being killed).