public abstract class TimeoutCounter extends Object
TimeoutCounter describes a timeout period to suspend thread
execution.
It uses the monotonic system clock, so it is never affected by the
change of the realtime system clock.
Note that this class is not synchronized. An instance of this class must not be shared with multiple threads.
| Constructor and Description |
|---|
TimeoutCounter() |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
await(Object obj)
Wait for the given object to be notified.
|
abstract long |
getRemains()
Return the number of nanoseconds to wait.
|
static TimeoutCounter |
newInfiniteTimeout()
Create a new timeout counter that waits for the notification with
infinite timeout.
|
static TimeoutCounter |
newTimeout(long timeout,
TimeUnit unit)
Create a new timeout counter that waits for the notificaition within
the specified timeout.
|
public static final TimeoutCounter newInfiniteTimeout()
TimeoutCounter instance that has an infinite timeout.public static final TimeoutCounter newTimeout(long timeout, TimeUnit unit)
timeout - The maximum time to wait.
Zero or a negative value is treated as an infinite
timeout.unit - The time unit of the timeout argument.TimeoutCounter instance.NullPointerException - unit is null.public abstract void await(Object obj) throws InterruptedException, TimeoutException
obj - An object to wait on.
Note that the caller hold the monitor of the specified
object.InterruptedException - The calling thread was interrupted.TimeoutException - The wait has been timed out.NullPointerException - obj is null.public abstract long getRemains()
throws TimeoutException
TimeoutException - The wait has been timed out.Copyright © 2018 OpenDaylight. All rights reserved.