Java Thread sleep
In some conditions, we might need to pause the execution of a thread for specific time or indefinite time. We have an inbuild option to accomplish this in the Thread class, the following methods are available for this.
sleep(long milliseconds,int nanoseconds)
Java Thread sleep Example
In the above example, we see thread is going for a sleep of 10seconds. After 10seconds, we see thread started execution.
Apart from the sleep we handled InterruptedException as well, for more information on the InterruptedException will discuss about this in the later chapters.