KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > util > concurrent > BlockingQueue


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.util.concurrent;
5
6 /**
7  * Adds methods to the regular queue interface for blocking queue implementations. Similar to <code>Queue</code>,
8  * this interface is modelled after the java.util.concurrent.BlockingQueue interface
9  *
10  * @author orion
11  */

12 public interface BlockingQueue extends Queue {
13   /**
14    * Place item in queue only if it can be accepted within the given timeout
15    *
16    * @param o the object to offer to the queue (should be non-null)
17    * @param timeout the number of milliseconds to wait. If less than or equal to zero, do not perform any timed waits
18    * @return true if accepted, else false
19    * @throws InterruptedException if the current thread has been interrupted at a point at which interruption is
20    * detected, in which case the element is guaranteed not to be inserted (i.e., is equivalent to a false
21    * return).
22    */

23   boolean offer(Object JavaDoc o, long timeout) throws InterruptedException JavaDoc;
24
25   /**
26    * Return and remove an item from channel only if one is available within the given timeout period
27    *
28    * @param timeout the number of milliseconds to wait. If less than or equal to zero, do not perform any timed waits
29    * @return an item, or null if the channel is empty.
30    * @throws InterruptedException if the current thread has been interrupted at a point at which interruption is
31    * detected, in which case state of the channel is unchanged (i.e., equivalent to a null return).
32    */

33   Object JavaDoc poll(long timeout) throws InterruptedException JavaDoc;
34
35   /**
36    * Return and remove an item from this queue, possibly waiting indefinitely until such an item exists.
37    *
38    * @return an item from the queue. Order of the return item (vs. insertion order) is governed by the implementation
39    * @throws InterruptedException if the current thread has been interrupted at a point at which interruption is
40    * detected, in which case state of the queue is unchanged.
41    */

42   Object JavaDoc take() throws InterruptedException JavaDoc;
43 }
Popular Tags