If we want the currently executing thread to sleep for a certain amount of time (e.g.:milliseconds), we can use java.lang.Thread.sleep(long millis) method.
Public static void sleep(long millis) throws InterruptedException millis is the amount of time to sleep in milliseconds.
The java.lang.Thread.sleep(long millis) system makes the presently running thread sleep for the defined number of milliseconds, directed to the precision and efficiency of system timers and schedulers.
The value of argument for milliseconds can never be negative, and it launches IllegalArgumentException.
When any of the threads disrupted the current thread. The disrupted status of the current thread is released when this exception is launched.
The thread.sleep() technique can be applied to pause the current thread running for a defined time in milliseconds.
Sleep time in ms =2000
|