indeed, simple and elegant and would do the job for most.

My application can't block on empty queue though.  The oswego queue has
timeout and retry features in it I need to use.

thanks much.
Korosh.



On Mon, 2004-01-26 at 17:08, Niclas Hedhman wrote:
> 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]
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to