// class FIFO

Public class Queue
{
	private List myFifo = new ArrayList()
	
	private List listOfConsumers = new ArrayList()
	
	
	public void synchronized addConsumer(Object oBj)
	{
		listOfConsumers.add(oBj);
	}
	
	public synchronized addElement(Object obj)
	{
		myFifo.add(obj);
		notifyConsumers();
	}
	
	public synchronized Object getFirstElement()
	{
		if(myFifo.isEmpty)
		{
			return null;
		}
		else
		{
			Object obj = myFifo.get(0);
			myFifo.remove(obj);
			notifyConsumers();
		}
	}
	
	public synchronized boolean isEmpty()
	{
	
	}
	
	// Notifier tous les consomatteurs de l'arrivée d'une requette
	private synchronized void notifyConsumers()
	{
		Iterator oIter = listOfConsumers.iterator();
        
        while (oIter.hasNext())
        {
            oIter.next().notify();
        }
	}
}// end of Queue


// Consomateur
public class Consumer extends Thread
{
	private Queue myQueue = null;
	
	private Consumer(Queue aQueue)
	{
		myQueue = aQueue
	} 

	public run()
	{
		while(true)
		{
			if(myQueue.isEmpty())
			{
				// attendre une notification
				wait();
			}
			else
			{
				Object obj = myQueue.getFirstElement();
				if(obj != null)
				{
				// le traitement à faire
				}
			}
		}
	}
}// end of class Consumer



public static void main(String[] _)
{
  Queue oQueue = new Queue();
  Consumer oConsumer = new Consumer();
  oQueue.addConsumer(oConsumer);
  oConsumer.start();
}