docs/doc/reference/com/google/android/exoplayer2/util/ConditionVariable.html
Package com.google.android.exoplayer2.util
[@Deprecated](https://developer.android.com/reference/java/lang/Deprecated.html "class or interface in java.lang")public classConditionVariableextends[Object](https://developer.android.com/reference/java/lang/Object.html "class or interface in java.lang")
Deprecated. com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
An interruptible condition variable. This class provides a number of benefits over ConditionVariable:
Consistent use of (Clock.elapsedRealtime() for timing block(long) timeout intervals. ConditionVariable used System.currentTimeMillis() prior to Android 10, which is not a correct clock to use for interval timing because it's not guaranteed to be monotonic.
Support for injecting a custom Clock.
The ability to query the variable's current state, by calling isOpen().
open() and close() return whether they changed the variable's state.
Constructors | Constructor | Description |
| --- | --- |
| ConditionVariable() |
Deprecated.
Creates a closed instance using Clock.DEFAULT.
|
| ConditionVariable(Clock clock) |
Deprecated.
Creates an instance, which starts closed. |
All Methods Instance Methods Concrete Methods Deprecated Methods | Modifier and Type | Method | Description |
| --- | --- | --- |
| void | block() |
Deprecated.
Blocks until the condition is opened.
|
| boolean | block(long timeoutMs) |
Deprecated.
Blocks until the condition is opened or until timeoutMs have passed.
|
| void | blockUninterruptible() |
Deprecated.
Blocks until the condition is open.
|
| boolean | close() |
Deprecated.
Closes the condition.
|
| boolean | isOpen() |
Deprecated.
Returns whether the condition is opened.
|
| boolean | open() |
Deprecated.
Opens the condition and releases all threads that are blocked. |
-
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public ConditionVariable()
Deprecated.
Creates a closed instance using Clock.DEFAULT.
-
public ConditionVariable([Clock](Clock.html "interface in com.google.android.exoplayer2.util")clock)
Deprecated.
Creates an instance, which starts closed.
Parameters:clock - The Clock whose Clock.elapsedRealtime() method is used to determine when block(long) should time out.
-
public boolean open()
Deprecated.
Opens the condition and releases all threads that are blocked. Returns:True if the condition variable was opened. False if it was already open.
-
public boolean close()
Deprecated.
Closes the condition. Returns:True if the condition variable was closed. False if it was already closed.
-
public void block()
throws[InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html "class or interface in java.lang")
Deprecated.
Blocks until the condition is opened.
Throws:InterruptedException - If the thread is interrupted.
-
public boolean block(long timeoutMs)
throws[InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException.html "class or interface in java.lang")
Deprecated.
Blocks until the condition is opened or until timeoutMs have passed.
Parameters:timeoutMs - The maximum time to wait in milliseconds. If timeoutMs <= 0 then the call will return immediately without blocking.Returns:True if the condition was opened, false if the call returns because of the timeout.Throws:InterruptedException - If the thread is interrupted.
-
public void blockUninterruptible()
Deprecated.
Blocks until the condition is open. Unlike block(), this method will continue to block if the calling thread is interrupted. If the calling thread was interrupted then its interrupted status will be set when the method returns.
-
public boolean isOpen()
Deprecated.
Returns whether the condition is opened.