background preloader

Java and IDEs

Facebook Twitter

Pausing Execution with Sleep (The Java™ Tutorials > Essential Classes > Concurrency) 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. The sleep method can also be used for pacing, as shown in the example that follows, and waiting for another thread with duties that are understood to have time requirements, as with the SimpleThreads example in a later section.

Two overloaded versions of sleep are provided: one that specifies the sleep time to the millisecond and one that specifies the sleep time to the nanosecond. However, these sleep times are not guaranteed to be precise, because they are limited by the facilities provided by the underlying OS. Also, the sleep period can be terminated by interrupts, as we'll see in a later section.

In any case, you cannot assume that invoking sleep will suspend the thread for precisely the time period specified. Java Tutorial. Getting Started With the NetBeans IDE Tutorial. Oracle Technology Network > Java Software Downloads View All Downloads Top Downloads New Downloads What's New Java in the Cloud: Rapidly develop and deploy Java business applications in the cloud.

Essential Links Developer Spotlight Java EE—the Most Lightweight Enterprise Framework? Blogs Technologies Contact Us About Oracle Cloud Events Top Actions News Key Topics Oracle Integrated Cloud Applications & Platform Services. Guided Video Tours of the NetBeans IDE. JDK 7 with NetBeans. Overview (Java 2 Platform SE 5.0)