1 21 22 package org.opensubsystems.core.util; 23 24 import java.util.LinkedList ; 25 import java.util.List ; 26 27 37 public class SynchronizedQueue 38 { 39 41 44 protected List m_lstObjects; 45 46 48 51 public SynchronizedQueue( 52 ) 53 { 54 super(); 55 56 m_lstObjects = new LinkedList (); 57 } 58 59 61 67 protected void finalize( 68 ) throws Throwable 69 { 70 m_lstObjects.clear(); 72 m_lstObjects = null; 73 74 super.finalize(); 75 } 76 77 87 public synchronized Object get( 88 ) throws InterruptedException 89 { 90 Object objReturn = null; 91 92 if (m_lstObjects.isEmpty()) 93 { 94 try 96 { 97 wait(); 98 } 99 catch (InterruptedException ieException) 100 { 101 if (m_lstObjects.isEmpty()) 108 { 109 throw ieException; 110 } 111 } 112 } 113 114 objReturn = m_lstObjects.remove(0); 116 117 return objReturn; 118 } 119 120 125 public synchronized void put( 126 Object objNew 127 ) 128 { 129 m_lstObjects.add(objNew); 130 notifyAll(); 132 } 133 134 139 public synchronized boolean isEmpty( 140 ) 141 { 142 return m_lstObjects.isEmpty(); 143 } 144 } 145 | Popular Tags |