ch.epfl.lpd.ids.utils
Class MyBlockingQueue<T>

java.lang.Object
  extended by ch.epfl.lpd.ids.utils.MyBlockingQueue<T>
All Implemented Interfaces:
IBlockingQueue<T>

public class MyBlockingQueue<T>
extends Object
implements IBlockingQueue<T>

Class implementing the IBlockingQueue. This class represents a blocking queue and waits until no new element are in the queue. This class is generic and accepts objects of type T.

Author:
Sebastien Baehni

Field Summary
protected  ArrayList<T> arrayList
          The array containing all the objects of the queue.
 
Constructor Summary
MyBlockingQueue()
          Creates a new instance of MyBlockingQueue.
 
Method Summary
 T get()
          Method used to retrieve the last, and not already get, element of this queue.
 void put(T obj)
          Method used to put a new element of type T into the queue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

arrayList

protected ArrayList<T> arrayList
The array containing all the objects of the queue.

Constructor Detail

MyBlockingQueue

public MyBlockingQueue()
Creates a new instance of MyBlockingQueue. This creates only an empty ArrayList

Method Detail

get

public T get()
      throws InterruptedException
Method used to retrieve the last, and not already get, element of this queue. This method waits until a new element is put into the queue.

Specified by:
get in interface IBlockingQueue<T>
Returns:
The last object of this queue that has not already been retrieved.
Throws:
InterruptedException - If an exception occurs while waiting for getting the last element of the queue.

put

public void put(T obj)
Method used to put a new element of type T into the queue

Specified by:
put in interface IBlockingQueue<T>
Parameters:
obj - The object to put into the queue.