Sleep() method in Java | Core Java Tutorials

This “Sleep() method in Java” is providing clear information about how to stop thread execution for specified number of milliseconds using pre defined Thread class method.


sleep() method:

  • Pre defined method of Thread class.
  • It is class level method(static).
  • Used to stop Thread execution for specified number of milliseconds.
  • Following one represents prototype of sleep method.

sleep() method in Java Thread


  • In single threaded app, execution ends @ main thread always.
  • When number of threads are executing, which thread completes its execution is completely depends on logic.
  • In some situations, main-thread completes execution before child thread.
  • Following example practically proves…..


Share this