Java Utililty Methods Thread Pause

List of utility methods to do Thread Pause

Description

The list of methods to do Thread Pause are organized into topic(s).

Method

voidpause(final int msec)
A basic sleep where you don't care about the interrupted exception.
if (msec > 0) {
    try {
        Thread.sleep(msec);
    } catch (final InterruptedException e) {
voidpause()
pauses a thread
pause(300);
voidpause(double seconds)
pause
if (seconds <= 0)
    return;
long sleepT, waitUntil = System.currentTimeMillis() + Math.round(seconds * 1000.0);
do {
    sleepT = waitUntil - System.currentTimeMillis();
    if (sleepT > 0) {
        try {
            Thread.sleep(sleepT);
...
voidpause(double seconds)
pause
if (seconds <= 0)
    return;
try {
    Thread.sleep(Math.round(seconds * 1000.0));
} catch (InterruptedException e) {
    throw new RuntimeException(e);
voidpause(double timeInSec)
pause
long start = System.currentTimeMillis();
while (System.currentTimeMillis() < (start + (timeInSec * 1000))) {
voidpause(final long time)
Causes the executing thread to pause for a period of time.
final long startTime = System.currentTimeMillis();
do {
    try {
        final long sleepTime = time - (System.currentTimeMillis() - startTime);
        Thread.sleep(sleepTime > 0 ? sleepTime : 10);
    } catch (InterruptedException e) {
} while ((System.currentTimeMillis() - startTime) < time);
...
voidpause(int i, String unit)
pause
try {
    switch (unit) {
    case "ms":
        Thread.sleep(i);
        break;
    case "s":
        Thread.sleep(i * 1000);
        break;
...
voidpause(int millis)
sleeps for millis milliseconds, approximately.
try {
    Thread.sleep(millis); 
} catch (InterruptedException ie) {
booleanpause(int millis)
Puts the the thread to sleep
try {
    Thread.sleep(millis);
} catch (InterruptedException e) {
    e.printStackTrace();
    return false;
return true;
voidpause(int milliseconds)
pause
try {
    Thread.sleep(milliseconds);
} catch (InterruptedException e) {
    e.printStackTrace();