133 * if (count == 0) {
134 * notEmpty.timedwait(msecs);
135 * if (count == 0)
136 * return null;
137 * }
138 * x = array[takePtr];
139 * array[takePtr] = null;
140 * takePtr = (takePtr + 1) % array.length;
141 * --count;
142 * notFull.signal();
143 * }
144 * finally {
145 * mutex.release();
146 * }
147 * return x;
148 * }
149 * }
150 *
151 * </pre>
152 * @see Mutex
153 * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
154
155 **/
156
157 public class CondVar {
158
159 protected boolean debug_ ;
160
161 /** The mutex **/
162 protected final Sync mutex_;
163 protected final ReentrantMutex remutex_;
164
165 private int releaseMutex()
166 {
167 int count = 1 ;
168
169 if (remutex_!=null)
170 count = remutex_.releaseAll() ;
171 else
172 mutex_.release() ;
173
174 return count ;
|
133 * if (count == 0) {
134 * notEmpty.timedwait(msecs);
135 * if (count == 0)
136 * return null;
137 * }
138 * x = array[takePtr];
139 * array[takePtr] = null;
140 * takePtr = (takePtr + 1) % array.length;
141 * --count;
142 * notFull.signal();
143 * }
144 * finally {
145 * mutex.release();
146 * }
147 * return x;
148 * }
149 * }
150 *
151 * </pre>
152 * @see Mutex
153 * [<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
154 **/
155
156 public class CondVar {
157
158 protected boolean debug_ ;
159
160 /** The mutex **/
161 protected final Sync mutex_;
162 protected final ReentrantMutex remutex_;
163
164 private int releaseMutex()
165 {
166 int count = 1 ;
167
168 if (remutex_!=null)
169 count = remutex_.releaseAll() ;
170 else
171 mutex_.release() ;
172
173 return count ;
|