Interface BlockingStack<N>
- All Superinterfaces:
Stack<N>
- All Known Implementing Classes:
ConcurrentStack
Created by jcairns on 2/16/16.
-
Method Summary
Modifier and TypeMethodDescriptionPop an element from the stack, waiting if necessary if the stack is currently emptyPop an element from the stack, waiting as long as required for an element to become available on the stackboolean
Push an element on the stack, waiting if necessary if the stack is currently fullvoid
Push an element on the stack waiting as long as required for space to become available
-
Method Details
-
push
Push an element on the stack, waiting if necessary if the stack is currently full- Parameters:
n
- - the element to push on the stacktime
- - the maximum time to waitunit
- - unit of waiting time- Returns:
- boolean - true if item was pushed, false otherwise
- Throws:
InterruptedException
- on interrupt
-
pushInterruptibly
Push an element on the stack waiting as long as required for space to become available- Parameters:
n
- - the element to push- Throws:
InterruptedException
- - in the event the current thread is interrupted prior to pushing the element
-
pop
Pop an element from the stack, waiting if necessary if the stack is currently empty- Parameters:
time
- - the maximum time to waitunit
- - the time unit for the waiting time- Returns:
- N - the popped element, or null in the event of a timeout
- Throws:
InterruptedException
- on interrupt
-
popInterruptibly
Pop an element from the stack, waiting as long as required for an element to become available on the stack- Returns:
- N - the popped element
- Throws:
InterruptedException
- - in the event the current thread is interrupted prior to popping any element
-