• BlackBerry Dynamics
  • Runtime library for Android applications
  • 12.0.1.79
WaitingThread Class Reference

Represents a thread waiting for a connection. More...

Description

This class implements throwaway objects. It is instantiated whenever a thread needs to wait. Instances are not re-used, except if the waiting thread experiences a spurious wakeup and continues to wait.
All methods assume external synchronization on the condition passed to the constructor. Instances of this class do not synchronize access!

Author
Roland Weber

Notice

The following notice applies to the original API on which this API is based, and to its documentation. The documentation of this API has been revised from the original.

/*
 * Copyright (C) 2006 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Public Member Functions

 WaitingThread (Condition cond, RouteSpecificPool pool)
 Creates a new entry for a waiting thread. More...
 
final Condition getCondition ()
 Obtains the condition. More...
 
final RouteSpecificPool getPool ()
 Obtains the pool, if there is one. More...
 
final Thread getThread ()
 Obtains the thread, if there is one. More...
 
boolean await (Date deadline) throws InterruptedException
 Blocks the calling thread. More...
 
void wakeup ()
 Wakes up the waiting thread. More...
 

Constructor & Destructor Documentation

◆ WaitingThread()

WaitingThread ( Condition  cond,
RouteSpecificPool  pool 
)
Parameters
condthe condition for which to wait
poolthe pool on which the thread will be waiting, or null

Member Function Documentation

◆ getCondition()

final Condition getCondition ( )
Returns
the condition on which to wait, never null

◆ getPool()

final RouteSpecificPool getPool ( )
Returns
the pool on which a thread is or was waiting, or null

◆ getThread()

final Thread getThread ( )
Returns
the thread which is waiting, or null

◆ await()

boolean await ( Date  deadline) throws InterruptedException

This method returns when the thread is notified or interrupted, if a timeout occurrs, or if there is a spurious wakeup.
This method assumes external synchronization.

Parameters
deadlinewhen to time out, or null for no timeout
Returns
true if the condition was satisfied, false in case of a timeout. Typically, a call to wakeup is used to indicate that the condition was satisfied. Since the condition is accessible outside, this cannot be guaranteed though.
Exceptions
InterruptedExceptionif the waiting thread was interrupted
See also
wakeup

◆ wakeup()

void wakeup ( )


This method assumes external synchronization.