Java Concurrency - Timing (time-out based operations)

> Procedural Languages > Java > Java - Concurrency (Parallel Work)

1 - java.util.concurrent

Java Concurrency - java.util.concurrent: The TimeUnit class provides multiple granularities (including nanoseconds) for specifying and controlling time-out based operations.

Most classes in the package contain operations based on time-outs in addition to indefinite waits.

In all cases that time-outs are used, the time-out specifies the minimum time that the method should wait before indicating that it timed-out.

Implementations make a “best effort” to detect time-outs as soon as possible after they occur. However, an indefinite amount of time may elapse between a time-out being detected and a thread actually executing again after that time-out.

All methods that accept timeout parameters treat values less than or equal to zero to mean not to wait at all. To wait “forever”, you can use a value of Long.MAX_VALUE.