# AbstractQueuedLongSynchronizer.ConditionObject

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#pubctors)\|[Methods](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#pubmethods)\|[Protected Methods](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#promethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#inhmethods)  

# AbstractQueuedLongSynchronizer.ConditionObject

`
public


class
AbstractQueuedLongSynchronizer.ConditionObject
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[Condition](https://developer.android.com/reference/java/util/concurrent/locks/Condition)`,

`[Serializable](https://developer.android.com/reference/java/io/Serializable)`


`

|---|---------------------------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.util.concurrent.locks.AbstractQueuedLongSynchronizer.ConditionObject |

<br />

*** ** * ** ***

Condition implementation for a[AbstractQueuedLongSynchronizer](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer)serving as the basis of a[Lock](https://developer.android.com/reference/java/util/concurrent/locks/Lock)implementation.

Method documentation for this class describes mechanics, not behavioral specifications from the point of view of Lock and Condition users. Exported versions of this class will in general need to be accompanied by documentation describing condition semantics that rely on those of the associated`AbstractQueuedLongSynchronizer`.

This class is Serializable, but all fields are transient, so deserialized conditions have no waiters.

## Summary

|                                                                                          ### Public constructors                                                                                          ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[ConditionObject](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#ConditionObject())`() ` Creates a new`ConditionObject`instance. |

|                                                                                                                                                          ### Public methods                                                                                                                                                           ||
|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final void`    | ` `[await](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#await())`() ` Implements interruptible condition wait.                                                                                                                                 |
| ` final boolean` | ` `[await](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#await(long,%20java.util.concurrent.TimeUnit))`(long time, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` unit) ` Implements timed condition wait. |
| ` final long`    | ` `[awaitNanos](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#awaitNanos(long))`(long nanosTimeout) ` Implements timed condition wait.                                                                                                          |
| ` final void`    | ` `[awaitUninterruptibly](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#awaitUninterruptibly())`() ` Implements uninterruptible condition wait.                                                                                                 |
| ` final boolean` | ` `[awaitUntil](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#awaitUntil(java.util.Date))`(`[Date](https://developer.android.com/reference/java/util/Date)` deadline) ` Implements absolute timed condition wait.                               |
| ` final void`    | ` `[signal](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#signal())`() ` Moves the longest-waiting thread, if one exists, from the wait queue for this condition to the wait queue for the owning lock.                                         |
| ` final void`    | ` `[signalAll](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#signalAll())`() ` Moves all threads from the wait queue for this condition to the wait queue for the owning lock.                                                                  |

|                                                                                                                                                                                                ### Protected methods                                                                                                                                                                                                 ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final int`                                                                                                                                                | ` `[getWaitQueueLength](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#getWaitQueueLength())`() ` Returns an estimate of the number of threads waiting on this condition.            |
| ` final `[Collection](https://developer.android.com/reference/java/util/Collection)`<`[Thread](https://developer.android.com/reference/java/lang/Thread)`>` | ` `[getWaitingThreads](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#getWaitingThreads())`() ` Returns a collection containing those threads that may be waiting on this Condition. |
| ` final boolean`                                                                                                                                            | ` `[hasWaiters](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.ConditionObject#hasWaiters())`() ` Queries whether any threads are waiting on this condition.                                         |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||
| From interface` `[java.util.concurrent.locks.Condition](https://developer.android.com/reference/java/util/concurrent/locks/Condition)` ` |---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void`    | ` `[await](https://developer.android.com/reference/java/util/concurrent/locks/Condition#await())`() ` Causes the current thread to wait until it is signalled or[interrupted](https://developer.android.com/reference/java/lang/Thread#interrupt()).                                                                                                         | | ` abstract boolean` | ` `[await](https://developer.android.com/reference/java/util/concurrent/locks/Condition#await(long,%20java.util.concurrent.TimeUnit))`(long time, `[TimeUnit](https://developer.android.com/reference/java/util/concurrent/TimeUnit)` unit) ` Causes the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses. | | ` abstract long`    | ` `[awaitNanos](https://developer.android.com/reference/java/util/concurrent/locks/Condition#awaitNanos(long))`(long nanosTimeout) ` Causes the current thread to wait until it is signalled or interrupted, or the specified waiting time elapses.                                                                                                          | | ` abstract void`    | ` `[awaitUninterruptibly](https://developer.android.com/reference/java/util/concurrent/locks/Condition#awaitUninterruptibly())`() ` Causes the current thread to wait until it is signalled.                                                                                                                                                                 | | ` abstract boolean` | ` `[awaitUntil](https://developer.android.com/reference/java/util/concurrent/locks/Condition#awaitUntil(java.util.Date))`(`[Date](https://developer.android.com/reference/java/util/Date)` deadline) ` Causes the current thread to wait until it is signalled or interrupted, or the specified deadline elapses.                                            | | ` abstract void`    | ` `[signal](https://developer.android.com/reference/java/util/concurrent/locks/Condition#signal())`() ` Wakes up one waiting thread.                                                                                                                                                                                                                         | | ` abstract void`    | ` `[signalAll](https://developer.android.com/reference/java/util/concurrent/locks/Condition#signalAll())`() ` Wakes up all waiting threads.                                                                                                                                                                                                                  | ||

## Public constructors

### ConditionObject

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public ConditionObject ()
```

Creates a new`ConditionObject`instance.

<br />

## Public methods

### await

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void await ()
```

Implements interruptible condition wait.

1. If current thread is interrupted, throw InterruptedException.
2. Save lock state returned by[AbstractQueuedLongSynchronizer.getState()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#getState()).
3. Invoke[AbstractQueuedLongSynchronizer.release(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#release(long))with saved state as argument, throwing IllegalMonitorStateException if it fails.
4. Block until signalled or interrupted.
5. Reacquire by invoking specialized version of[AbstractQueuedLongSynchronizer.acquire(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#acquire(long))with saved state as argument.
6. If interrupted while blocked in step 4, throw InterruptedException.

<br />

<br />

|                                              Throws                                               ||
|------------------------------------------------------------------------------------------------|---|
| [InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException) |   |

### await

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final boolean await (long time, 
                TimeUnit unit)
```

Implements timed condition wait.

1. If current thread is interrupted, throw InterruptedException.
2. Save lock state returned by[AbstractQueuedLongSynchronizer.getState()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#getState()).
3. Invoke[AbstractQueuedLongSynchronizer.release(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#release(long))with saved state as argument, throwing IllegalMonitorStateException if it fails.
4. Block until signalled, interrupted, or timed out.
5. Reacquire by invoking specialized version of[AbstractQueuedLongSynchronizer.acquire(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#acquire(long))with saved state as argument.
6. If interrupted while blocked in step 4, throw InterruptedException.
7. If timed out while blocked in step 4, return false, else true.

<br />

<br />

|                          Parameters                           ||
|--------|-------------------------------------------------------|
| `time` | `long`: the maximum time to wait <br />               |
| `unit` | `TimeUnit`: the time unit of the`time`argument <br /> |

|                                                  Returns                                                  ||
|-----------|------------------------------------------------------------------------------------------------|
| `boolean` | `false`if the waiting time detectably elapsed before return from the method, else`true` <br /> |

|                                              Throws                                               ||
|------------------------------------------------------------------------------------------------|---|
| [InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException) |   |

### awaitNanos

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final long awaitNanos (long nanosTimeout)
```

Implements timed condition wait.

1. If current thread is interrupted, throw InterruptedException.
2. Save lock state returned by[AbstractQueuedLongSynchronizer.getState()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#getState()).
3. Invoke[AbstractQueuedLongSynchronizer.release(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#release(long))with saved state as argument, throwing IllegalMonitorStateException if it fails.
4. Block until signalled, interrupted, or timed out.
5. Reacquire by invoking specialized version of[AbstractQueuedLongSynchronizer.acquire(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#acquire(long))with saved state as argument.
6. If interrupted while blocked in step 4, throw InterruptedException.

<br />

<br />

|                               Parameters                                ||
|----------------|---------------------------------------------------------|
| `nanosTimeout` | `long`: the maximum time to wait, in nanoseconds <br /> |

|                                                                                                                                                   Returns                                                                                                                                                   ||
|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `long` | an estimate of the`nanosTimeout`value minus the time spent waiting upon return from this method. A positive value may be used as the argument to a subsequent call to this method to finish waiting out the desired time. A value less than or equal to zero indicates that no time remains. <br /> |

|                                              Throws                                               ||
|------------------------------------------------------------------------------------------------|---|
| [InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException) |   |

### awaitUninterruptibly

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void awaitUninterruptibly ()
```

Implements uninterruptible condition wait.

1. Save lock state returned by[AbstractQueuedLongSynchronizer.getState()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#getState()).
2. Invoke[AbstractQueuedLongSynchronizer.release(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#release(long))with saved state as argument, throwing IllegalMonitorStateException if it fails.
3. Block until signalled.
4. Reacquire by invoking specialized version of[AbstractQueuedLongSynchronizer.acquire(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#acquire(long))with saved state as argument.

<br />

<br />

### awaitUntil

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final boolean awaitUntil (Date deadline)
```

Implements absolute timed condition wait.

1. If current thread is interrupted, throw InterruptedException.
2. Save lock state returned by[AbstractQueuedLongSynchronizer.getState()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#getState()).
3. Invoke[AbstractQueuedLongSynchronizer.release(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#release(long))with saved state as argument, throwing IllegalMonitorStateException if it fails.
4. Block until signalled, interrupted, or timed out.
5. Reacquire by invoking specialized version of[AbstractQueuedLongSynchronizer.acquire(long)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#acquire(long))with saved state as argument.
6. If interrupted while blocked in step 4, throw InterruptedException.
7. If timed out while blocked in step 4, return false, else true.

<br />

<br />

|                         Parameters                         ||
|------------|------------------------------------------------|
| `deadline` | `Date`: the absolute time to wait until <br /> |

|                                   Returns                                    ||
|-----------|-------------------------------------------------------------------|
| `boolean` | `false`if the deadline has elapsed upon return, else`true` <br /> |

|                                              Throws                                               ||
|------------------------------------------------------------------------------------------------|---|
| [InterruptedException](https://developer.android.com/reference/java/lang/InterruptedException) |   |

### signal

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void signal ()
```

Moves the longest-waiting thread, if one exists, from the wait queue for this condition to the wait queue for the owning lock.

<br />

|                                                                                                                                                   Throws                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalMonitorStateException](https://developer.android.com/reference/java/lang/IllegalMonitorStateException) | if[AbstractQueuedLongSynchronizer.isHeldExclusively()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#isHeldExclusively())returns`false` |

### signalAll

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void signalAll ()
```

Moves all threads from the wait queue for this condition to the wait queue for the owning lock.

<br />

|                                                                                                                                                   Throws                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalMonitorStateException](https://developer.android.com/reference/java/lang/IllegalMonitorStateException) | if[AbstractQueuedLongSynchronizer.isHeldExclusively()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#isHeldExclusively())returns`false` |

## Protected methods

### getWaitQueueLength

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected final int getWaitQueueLength ()
```

Returns an estimate of the number of threads waiting on this condition. Implements[AbstractQueuedLongSynchronizer.getWaitQueueLength(ConditionObject)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#getWaitQueueLength(java.util.concurrent.locks.AbstractQueuedLongSynchronizer.ConditionObject)).

<br />

|                        Returns                        ||
|-------|------------------------------------------------|
| `int` | the estimated number of waiting threads <br /> |

|                                                                                                                                                   Throws                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalMonitorStateException](https://developer.android.com/reference/java/lang/IllegalMonitorStateException) | if[AbstractQueuedLongSynchronizer.isHeldExclusively()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#isHeldExclusively())returns`false` |

### getWaitingThreads

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected final Collection<Thread> getWaitingThreads ()
```

Returns a collection containing those threads that may be waiting on this Condition. Implements[AbstractQueuedLongSynchronizer.getWaitingThreads(ConditionObject)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#getWaitingThreads(java.util.concurrent.locks.AbstractQueuedLongSynchronizer.ConditionObject)).

<br />

|                                                                                       Returns                                                                                        ||
|----------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| [Collection](https://developer.android.com/reference/java/util/Collection)`<`[Thread](https://developer.android.com/reference/java/lang/Thread)`>` | the collection of threads <br /> |

|                                                                                                                                                   Throws                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalMonitorStateException](https://developer.android.com/reference/java/lang/IllegalMonitorStateException) | if[AbstractQueuedLongSynchronizer.isHeldExclusively()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#isHeldExclusively())returns`false` |

### hasWaiters

Added in[API level 9](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected final boolean hasWaiters ()
```

Queries whether any threads are waiting on this condition. Implements[AbstractQueuedLongSynchronizer.hasWaiters(ConditionObject)](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#hasWaiters(java.util.concurrent.locks.AbstractQueuedLongSynchronizer.ConditionObject)).

<br />

|                         Returns                          ||
|-----------|-----------------------------------------------|
| `boolean` | `true`if there are any waiting threads <br /> |

|                                                                                                                                                   Throws                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalMonitorStateException](https://developer.android.com/reference/java/lang/IllegalMonitorStateException) | if[AbstractQueuedLongSynchronizer.isHeldExclusively()](https://developer.android.com/reference/java/util/concurrent/locks/AbstractQueuedLongSynchronizer#isHeldExclusively())returns`false` |