Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is difference between creating a thread by extending Thread class and implementing Runnable?

0
Posted

What is difference between creating a thread by extending Thread class and implementing Runnable?

0

Explain the four different states of a thread The four different states of a thread are new: When a thread is created with new operator .It is not yet running. Runnable: Once you invoke the start method on the thread it becomes runnable. It is up to the OS to decide when to give time to the thread to run. A runnable thread may or may not be running. Blocked : Thread enters this state under the following condition. Someone calls sleep () on the thread. Thread calls an operation that blocks on input/output. Thread calls wait() method. Thread tries to lock an object that is currently locked by another thread. Dead : The Thread is dead for one of two reasons. It dies a natural death because the run method exits normally. It dies abruptly because an uncaught exception terminates the run method.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123