Java Utililty Methods Thread Lock

List of utility methods to do Thread Lock

Description

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

Method

voidsleepNanos(long nanos)
sleep Nanos
if (nanos <= 0) {
    return;
LockSupport.parkNanos(nanos);
voidsleepRandomNanos(Random random, long maxDelayNanos)
Sleeps a random amount of time.
if (maxDelayNanos <= 0) {
    return;
long randomValue = Math.abs(random.nextLong());
long delayNanos = randomValue % maxDelayNanos;
LockSupport.parkNanos(delayNanos);