0 votes
in Python Flask by
Can you explain the life cycle of a thread?

1 Answer

0 votes
by

python scripting interview questions

  1. To create a thread, we create a class that we make override the run method of the thread class. Then, we instantiate it.
  2. A thread that we just created is in the new state. When we make a call to start() on it, it forwards the threads for scheduling. These are in the ready state.
  3. When execution begins, the thread is in the running state.
  4. Calls to methods like sleep() and join() make a thread wait. Such a thread is in the waiting/blocked state.
  5. When a thread is done waiting or executing, other waiting threads are sent for scheduling.
  6. A running thread that is done executing terminates and is in the dead state.

Related questions

0 votes
asked May 12, 2023 in Python Flask by SakshiSharma
0 votes
asked May 12, 2023 in Python Flask by SakshiSharma
...