Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we make a thread to sleep for a infinite time in java?

Pls help me to understand how can we make a thread to sleep for a infinite time period .

like image 683
Logesh Avatar asked Jun 15 '15 12:06

Logesh


People also ask

How do I make a thread sleep indefinitely?

You can specify Timeout. Infinite for the millisecondsTimeout parameter to suspend the thread indefinitely.

How can you pause the execution of a thread for a certain amount of time?

Thread. sleep() method can be used to pause the execution of current thread for specified time in milliseconds.


1 Answers

Thread.currentThread().join();

Will sleep until the JVM is killed.

like image 135
Taylor Gautier Avatar answered Nov 02 '22 23:11

Taylor Gautier