com.lti.utils.synchronization
Class ProducerConsumerQueue<T>
java.lang.Object
com.lti.utils.synchronization.ProducerConsumerQueue<T>
public class ProducerConsumerQueue<T>
- extends java.lang.Object
A synchronized queue where get/put waits if needed.
- Author:
- Ken Larson
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ProducerConsumerQueue
public ProducerConsumerQueue()
ProducerConsumerQueue
public ProducerConsumerQueue(int sizeLimit)
size
public int size()
sizeLimit
public int sizeLimit()
isFull
public boolean isFull()
isEmpty
public boolean isEmpty()
waitUntilNotEmpty
public void waitUntilNotEmpty()
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
waitUntilEmpty
public void waitUntilEmpty()
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
waitUntilNotEmpty
public boolean waitUntilNotEmpty(long timeout)
throws java.lang.InterruptedException
- Returns:
- true if success, false if timeout.
- Throws:
java.lang.InterruptedException
get
public T get()
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
get
public T get(long timeout,
T returnOnTimeout)
throws java.lang.InterruptedException
- Returns:
- returnOnTimeout if timeout.
- Throws:
java.lang.InterruptedException
put
public void put(T value)
throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
put
public boolean put(T value,
long timeout)
throws java.lang.InterruptedException
- Returns:
- false if timeout, true otherwise
- Throws:
java.lang.InterruptedException