Package org.apache.http.impl.conn.tsccm
Class WaitingThread
java.lang.Object
org.apache.http.impl.conn.tsccm.WaitingThread
public class WaitingThread extends Object
Represents a thread waiting for a connection.
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!
All methods assume external synchronization on the condition passed to the constructor. Instances of this class do not synchronize access!
- Author:
- Roland Weber
-
Constructor Summary
Constructors Constructor Description WaitingThread(Condition cond, RouteSpecificPool pool)Creates a new entry for a waiting thread. -
Method Summary
Modifier and Type Method Description booleanawait(Date deadline)Blocks the calling thread.ConditiongetCondition()Obtains the condition.RouteSpecificPoolgetPool()Obtains the pool, if there is one.ThreadgetThread()Obtains the thread, if there is one.voidinterrupt()voidwakeup()Wakes up the waiting thread.
-
Constructor Details
-
WaitingThread
Creates a new entry for a waiting thread.- Parameters:
cond- the condition for which to waitpool- the pool on which the thread will be waiting, ornull
-
-
Method Details
-
getCondition
Obtains the condition.- Returns:
- the condition on which to wait, never
null
-
getPool
Obtains the pool, if there is one.- Returns:
- the pool on which a thread is or was waiting,
or
null
-
getThread
Obtains the thread, if there is one.- Returns:
- the thread which is waiting, or
null
-
await
Blocks the calling thread. 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:
deadline- when to time out, ornullfor no timeout- Returns:
trueif the condition was satisfied,falsein case of a timeout. Typically, a call towakeup()is used to indicate that the condition was satisfied. Since the condition is accessible outside, this cannot be guaranteed though.- Throws:
InterruptedException- if the waiting thread was interrupted- See Also:
wakeup()
-
wakeup
public void wakeup()Wakes up the waiting thread.
This method assumes external synchronization. -
interrupt
public void interrupt()
-