Pausing Execution

suggest change

Thread.sleep causes the current thread to suspend execution for a specified period. This is an efficient means of making processor time available to the other threads of an application or other applications that might be running on a computer system. There are two overloaded sleep methods in the Thread class. One that specifies the sleep time to the millisecond

public static void sleep(long millis) throws InterruptedException

One that specifies the sleep time to the nanosecond

public static void sleep(long millis, int nanos)

Pausing Execution for 1 second

Thread.sleep(1000);

It is important to note that this is a hint to the operating system’s kernel’s scheduler. This may not necessarily be precise, and some implementations do not even consider the nanosecond parameter (possibly rounding to the nearest millisecond).

It is recommended to enclose a call to Thread.sleep in try/catch and catch InterruptedException.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Concurrent Programming Threads:
* Pausing Execution

Table Of Contents
8 Arrays
10 Maps
11 Strings
16 Concurrent Programming Threads
25 JAXB
29 Enums
32 Audio
41 Scanner
63 Logging
75 Lists
78 Sets
89 JAX-WS
96 XJC
98 Process
106 Modules
114 Applets
122 JNDI
139 JavaBean
141 Literals
144 Packages
150 JMX
153 JShell
159 Sockets
167 Enum Map
175 Hashtable
177 SortedMap