## org.mortbay.util
Class BlockingQueue

    java.lang.Object
      |
      +--org.mortbay.util.BlockingQueue

public class BlockingQueue
extends java.lang.Object

Blocking queue. XXX temp implementation. Should use java2 containers. Implemented as circular buffer in a Vector. Synchronization is on the vector to avoid double synchronization.

Version:
  $Id: BlockingQueue.java,v 1.3 2002/10/04 18:59:51 gregwilkins Exp $
Author:
  Greg Wilkins (gregw)

Constructor Summary
`BlockingQueue(int maxSize)` Constructor.
`BlockingQueue(java.lang.Object lock, int maxSize)` Constructor.

Method Summary
`void` `clear()`
`java.lang.Object` `get()` Get object from queue.
`java.lang.Object` `get(int timeoutMs)` Get from queue.
`int` `maxSize()`
`java.lang.Object` `peek()` Peek at the queue.
`java.lang.Object` `peek(int timeoutMs)` Peek at the queue.
`void` `put(java.lang.Object o)` Put object in queue.
`void` `put(java.lang.Object o, int timeout)` Put object in queue.
`int` `size()`

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

Constructor Detail

### BlockingQueue

    public BlockingQueue(int maxSize)

  Constructor.

### BlockingQueue

    public BlockingQueue(java.lang.Object lock,
                         int maxSize)

  Constructor.

Method Detail

### clear

    public void clear()

### size

    public int size()

### maxSize

    public int maxSize()

### put

    public void put(java.lang.Object o)
             throws java.lang.InterruptedException

  Put object in queue.

  Parameters:
    `o` - Object
    `java.lang.InterruptedException`

### put

    public void put(java.lang.Object o,
                    int timeout)
             throws java.lang.InterruptedException

  Put object in queue.

  Parameters:
    `timeout` - If timeout expires, throw InterruptedException
    `o` - Object
  Throws:
    `java.lang.InterruptedException` - Timeout expired or otherwise interrupted

### get

    public java.lang.Object get()
                         throws java.lang.InterruptedException

  Get object from queue. Block if there are no objects to get.

  Returns:
    The next object in the queue.
    `java.lang.InterruptedException`

### get

    public java.lang.Object get(int timeoutMs)
                         throws java.lang.InterruptedException

  Get from queue. Block for timeout if there are no objects to get.

  Parameters:
    `timeoutMs` - the time to wait for a job
  Returns:
    The next object in the queue, or null if timedout.
    `java.lang.InterruptedException`

### peek

    public java.lang.Object peek()
                          throws java.lang.InterruptedException

  Peek at the queue. Block if there are no objects to peek.

  Returns:
    The next object in the queue, or null if timedout.
    `java.lang.InterruptedException`

### peek

    public java.lang.Object peek(int timeoutMs)
                          throws java.lang.InterruptedException

  Peek at the queue. Block for timeout if there are no objects to peek.

  Parameters:
    `timeoutMs` - the time to wait for a job
  Returns:
    The next object in the queue, or null if timedout.
    `java.lang.InterruptedException`

Copyright © 2000 Mortbay Consulting Pty. Ltd. All Rights Reserved.