## org.firebirdsql.pool
Class BlockingStack

    java.lang.Object
      org.firebirdsql.pool.BlockingStack

    public class BlockingStack

extends Object

Object stack that implements a blocking LIFO (last-in-first-out) stack. The implementation will block when the list is empty.

Author:
  Steven Jardine

Nested Class Summary
`protected class` `BlockingStack.Node` Container class for objects in the stack.

Field Summary
`protected BlockingStack.Node` `top` Actual top of the stack.
`protected Object` `topLock`
`protected int` `waiting` Number of threads waiting for an object.

Constructor Summary
`BlockingStack()`

Method Summary
`protected Object` `extract()`
`boolean` `isEmpty()` Checks to see if the stack is empty.
`Object` `peek()` Return, but do not remove, the object at the top of the stack.
`Object` `pop()` Return and remove the object at the top of the stack.
`Object` `pop(long msec)` Return and remove the object at the top of the stack only if it is available within the specified number of milliseconds, otherwise return null.
`void` `push(Object item)` Push an object onto the stack.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### top

    protected BlockingStack.Node top

  Actual top of the stack.

### waiting

    protected int waiting

  Number of threads waiting for an object.

### topLock

    protected Object topLock

Constructor Detail

### BlockingStack

    public BlockingStack()

Method Detail

### isEmpty

    public boolean isEmpty()

  Checks to see if the stack is empty.

  Returns:
    true if empty, false otherwise.

### peek

    public Object peek()

  Return, but do not remove, the object at the top of the stack.

  Returns:
    the object at the top of the stack, null if stack is empty.

### extract

    protected Object extract()

### pop

    public Object pop()
               throws InterruptedException

  Return and remove the object at the top of the stack. If the stack is empty, wait until an object exists.

  Returns:
    the object at the top of the stack.
  Throws:
    `InterruptedException`

### pop

    public Object pop(long msec)
               throws InterruptedException

  Return and remove the object at the top of the stack only if it is available within the specified number of milliseconds, otherwise return null.

  Parameters:
    `msec` - to wait for an object before returning null.
  Returns:
    the object at the top of the stack.
  Throws:
    `InterruptedException`

### push

    public void push(Object item)
              throws InterruptedException

  Push an object onto the stack. If the stack is unavailable, wait until it becomes available.

  Parameters:
    `item` - to be pushed onto the stack.
  Throws:
    `InterruptedException`

Copyright © 2001-2010. All Rights Reserved.