com.flat502.rox.utils
Class ThreadQueue

java.lang.Object
  extended by com.flat502.rox.utils.ThreadQueue

public class ThreadQueue
extends java.lang.Object

This class implements a queue for blocking and releasing threads in a FIFO order.

When a thread calls the capture() method it is blocked until release() is invoked. Threads are guaranteed to be released in the order in which they were captured.

This class is used to ensure fairness when sharing finite resources across multiple threads.


Constructor Summary
ThreadQueue()
           
ThreadQueue(java.lang.Object mutex)
           
 
Method Summary
 void capture()
           
 void capture(long timeout)
           
 void release()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadQueue

public ThreadQueue()

ThreadQueue

public ThreadQueue(java.lang.Object mutex)
Method Detail

capture

public void capture()

capture

public void capture(long timeout)
             throws CaptureTimeoutException
Throws:
CaptureTimeoutException

release

public void release()