Jadex 0.941

jadex.util.collection
Class BlockingQueue

java.lang.Object
  extended byjadex.util.collection.BlockingQueue
All Implemented Interfaces:
IBlockingQueue

public class BlockingQueue
extends Object
implements IBlockingQueue

A blocking queue allows to enqueue or dequeue elements. It blocks, when it is tried to dequeue an element, but the queue is empty.


Nested Class Summary
 
Nested classes inherited from class jadex.util.collection.IBlockingQueue
IBlockingQueue.ClosedException, IBlockingQueue.TimeoutException
 
Constructor Summary
BlockingQueue()
          Create a blocking queue.
 
Method Summary
 Object dequeue()
          Dequeue an element.
 Object dequeue(long timeout)
          Dequeue an element.
 void enqueue(Object element)
          Enqueue an element.
static void main(String[] args)
          Main for testing.
 void setClosed(boolean closed)
          Open/close the queue.
 int size()
          Return the size of the queue.
static void test1(String[] args)
          Main for testing.
static void test1b(String[] args)
          Main for testing.
static void test2(String[] args)
          Main for testing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockingQueue

public BlockingQueue()
Create a blocking queue.

Method Detail

enqueue

public void enqueue(Object element)
Enqueue an element.

Specified by:
enqueue in interface IBlockingQueue
Parameters:
element - The element.

dequeue

public Object dequeue(long timeout)
               throws IBlockingQueue.ClosedException,
                      IBlockingQueue.TimeoutException
Dequeue an element.

Specified by:
dequeue in interface IBlockingQueue
Parameters:
timeout - the time to wait (in millis) or -1 for no timeout.
Returns:
The element. When queue is empty the methods blocks until an element is added or the timeout occurs.
Throws:
IBlockingQueue.ClosedException
IBlockingQueue.TimeoutException

dequeue

public Object dequeue()
               throws IBlockingQueue.ClosedException
Dequeue an element.

Specified by:
dequeue in interface IBlockingQueue
Returns:
The element. When queue is empty the methods blocks until an element is added.
Throws:
IBlockingQueue.ClosedException

setClosed

public void setClosed(boolean closed)
Open/close the queue.

Specified by:
setClosed in interface IBlockingQueue
Parameters:
closed - The closed state.

size

public int size()
Return the size of the queue.

Specified by:
size in interface IBlockingQueue
Returns:
The size.

main

public static void main(String[] args)
                 throws InterruptedException
Main for testing.

Throws:
InterruptedException

test1

public static void test1(String[] args)
                  throws InterruptedException
Main for testing.

Throws:
InterruptedException

test1b

public static void test1b(String[] args)
                   throws InterruptedException
Main for testing.

Throws:
InterruptedException

test2

public static void test2(String[] args)
                  throws InterruptedException
Main for testing.

Throws:
InterruptedException

Jadex 0.941

Submit a bug or feature
For further API reference and developer documentation, see the Jadex User Guide and the Jadex Tutorial. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, and working code examples.

Copyright (C) 2002-2005 Lars Braubach, Alexander Pokahr, Andrzej Walczak - University of Hamburg. Use is subject to license terms.