On Monday 26 January 2004 13:01, korosh afshar wrote: > Is there a one in existance ? > > I need to be "put"ting and "poll"ing from one that is threadsafe. > > I was going to start on making Doug Lee's implementation ( > EDU.oswego.cs.dl.util.concurrent.BoundedBuffer) into a merlin component > but thought I ask first.
You don't need to travel over the river to pick up some water. ;o) You probably need the following; Cheers Niclas public class SimpleFIFO { private ArrayList m_Queue; public SimpleFIFO() { m_Queue = new ArrayList(); } public void clear() { synchronized( this ) { m_Queue.clear(); } } public void put( Object obj ) { synchronized( this ) { m_Queue.add( obj ); notifyAll(); } } public Object get() throws InterruptedException { synchronized( this ) { while( m_Queue.size() == 0 ) wait(100); return m_Queue.remove(0); } } public int size() { synchronized( this ) { return m_Queue.size(); } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]