org.mortbay.util
Class BlockingQueue
java.lang.Object
org.mortbay.util.BlockingQueue
public class BlockingQueue
extends java.lang.Object
Blocking queue.
Implemented as circular buffer in a Vector. Synchronization is on the
vector to avoid double synchronization.
$Id: BlockingQueue.java,v 1.5 2004/05/09 20:32:49 gregwilkins Exp $
void | clear()
|
Object | get() - Get object from queue.
|
Object | get(int timeoutMs) - Get from queue.
|
int | maxSize()
|
Object | peek() - Peek at the queue.
|
Object | peek(int timeoutMs) - Peek at the queue.
|
void | put(Object o) - Put object in queue.
|
void | put(Object o, int timeout) - Put object in queue.
|
int | size()
|
BlockingQueue
public BlockingQueue(Object lock,
int maxSize)
Constructor.
BlockingQueue
public BlockingQueue(int maxSize)
Constructor.
get
public Object get()
throws InterruptedException
Get object from queue.
Block if there are no objects to get.
- The next object in the queue.
get
public Object get(int timeoutMs)
throws InterruptedException
Get from queue.
Block for timeout if there are no objects to get.
timeoutMs
- the time to wait for a job
- The next object in the queue, or null if timedout.
maxSize
public int maxSize()
peek
public Object peek()
throws InterruptedException
Peek at the queue.
Block if there are no objects to peek.
- The next object in the queue, or null if timedout.
peek
public Object peek(int timeoutMs)
throws InterruptedException
Peek at the queue.
Block for timeout if there are no objects to peek.
timeoutMs
- the time to wait for a job
- The next object in the queue, or null if timedout.
put
public void put(Object o)
throws InterruptedException
Put object in queue.
put
public void put(Object o,
int timeout)
throws InterruptedException
Put object in queue.
o
- Objecttimeout
- If timeout expires, throw InterruptedException
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.