Wednesday, 24 July 2019

How to stop, suspend and resume a Thread

Stop()
  • We can stop a Thread execution by using stop() of Thread class.
    • public void stop();
  • If we will call stop() then immediately the Thread will entered in dead state. Anyway stop() is depreciated and not recommended to use.
suspend() and resume()
  • A Thread can suspend another Thread by using suspend() method then that Thread will be paused temporarily.
    • public final void suspend();
  • A Thread can resume a suspended Thread by using resume() method then suspended Thread will continue its execution.
    • public final void resume();
  • Both methods are deprecated and not recommended to use.


Thanks..!!

No comments:

Post a Comment