fr.dyade.aaa.util

Class Queue


public class Queue
extends Vector

The Queue class implements a First-In-First-Out (FIFO) list of objects.

A queue is for the exclusive use of one single consumer, whereas many producers may access it. It is ready for use after instanciation. A producer may wait for the queue to be empty by calling the stop() method. This method returns when the queue is actually empty, and prohibitis any further call to the push method. To be able to use the queue again, it must be re-started through the start() method.

Constructor Summary

Queue()
Constructs a Queue instance.

Method Summary

Object
get()
Waits for an object to be pushed in the queue, and eventually returns it without removing it.
Object
pop()
Removes and returns the object at the top of this queue.
void
push(Object item)
Pushes an item at the end of this queue.
void
start()
Authorizes the use of the queue by producers.
void
stop()
Stops the queue by returning when it is empty and prohibiting any further producers call to the push method.

Constructor Details

Queue

public Queue()
Constructs a Queue instance.

Method Details

get

public Object get()
            throws InterruptedException
Waits for an object to be pushed in the queue, and eventually returns it without removing it.

Returns:
The object at the top of this queue.


pop

public Object pop()
Removes and returns the object at the top of this queue.

Returns:
The object at the top of this queue.


push

public void push(Object item)
Pushes an item at the end of this queue.

Parameters:
item - The item to be pushed at the end of this queue.


start

public void start()
Authorizes the use of the queue by producers.


stop

public void stop()
            throws InterruptedException
Stops the queue by returning when it is empty and prohibiting any further producers call to the push method.


Copyright B) 2004 Scalagent - All rights reserved