answersLogoWhite

0

What is the purpose of Java sleep?

Updated: 8/11/2023
User Avatar

Wiki User

10y ago

Best Answer

It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.

It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.

It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.

It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

While Implementing multithreading, either we implement a Runnable interface or we extend a Thread class or we may use a thread pool. in all these cases, we may have to use Sleep method. this is done for the following reason. we may use multiple thread in a program and it is to be noted that JVM( java virtual machine ) can execute one thread at a time. if we want parallel execution of threads, we need to stop the execution of one thread and start the execution of other thread simultaneously. in order to do this, we use sleep. Syntax : sleep(1000); here the thread having this method comes to non runnable state for 1000 milli seconds while the execution of other threads starts immedeately.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

The function known as Java sleep or sleep() was made with a purpose for developers, and programmers to be able to suspend a number of threads while executing the other lines of code in their respective programs.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

It pauses the execution of the program (or of the thread where it is invoked, if you have multiple threads), for the specified time.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the purpose of Java sleep?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the purpose of NoMatchException handling method in java?

java exception


What is the purpose of vector?

The purpose of vector Java is to make more Java possibilities for mobile and uniformed devices. The makers of Java said that they wanted to "revolutionize" the way that Java works and helps around the globe.


What is the purpose of Java Mobile?

Java is the leading mobile phone developers and carriers. The purpose of Java's Mobile Media API is to play record sounds and videos and to also capture still images.


What is java's purpose on my PC?

Programs that are specifically designed with Java require a Java runtime to work on a computer. (In the case of Java, the runtime is called "Java Virtual Machine".) If you have any such program, you need to have Java.


What is the purpose of claiming exceptions?

it informs compiler about its possible exceptions. For example,The purpose of Java exception is to tell the Java runtime system what can go wrong


What exception thrown by sleep method in java?

InterruptedException is thrown.


What is purpose of JVM?

JVM stands for Java Virtual Machine The JVM is the system in which our Java programs are executed.


What is the purpose of java methods?

go ask your monitor.


What is the purpose of java?

Curtly, portability and clean programming


What is the cultural purpose of gamelan music in java?

sound


What is the purpose of method in java?

go ask your monitor.


For what purpose is Sun Java used?

Sun Java is a computer software aimed at Java users. It's primary purpose is to make use of "immortal memory" allowing for memory to last forever without getting erased or expiring.