/*
 *   Copyright (c) 2003, Wireless Infrastructure Technology Services, Inc. 
 *   All Rights Reserved.
 *
 *   Wireless Infrastructure Technology Services, Inc.
 *   52 Pickering St.
 *   Needham, MA 02492
 *
 *   781-453-9487
 */


import java.util.*;


public class BlockingQueue
{
    private Vector queue;
    private Object lock;


    public BlockingQueue () {

        queue = new Vector ();
        lock = new Object();
    }


    public void add (Object o) {

        synchronized (lock) {
	      queue.add(o);
            lock.notify();
        }
    }


    public Object remove() {

        try {
            synchronized (lock) {
		    if (queue.size() == 0)
			  lock.wait();
                return queue.remove(0);
            }
        } catch (InterruptedException E) {
            return null;
        }
    }


    public int size () {
        return queue.size();
    }


}
