⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blockingfifolist.java

📁 一个关于java 的常用工具包
💻 JAVA
字号:
package org.jutil.java.collections;import java.util.List;import java.util.LinkedList;/** * <p>Synchronized fifo list that will block the request to pop the first object * until a first object is present.</p> * * <center> *   <img src="doc-files/BlockingFifoList.png"/> * </center> * * @path    $Source: /cvsroot/org-jutil/jutil.org/src/org/jutil/java/collections/BlockingFifoList.java,v $ * @version $Revision: 1.6 $ * @date    $Date: 2002/07/21 15:15:19 $ * @state   $State: Exp $ * @author  Tom Schrijvers * @author  Marko van Dooren * @release $Name:  $ */public class BlockingFifoList	extends FifoList {  /* The revision of this class */    public final static String CVS_REVISION ="$Revision: 1.6 $";	/**	 * Initialize a new empty blocking fifo list.	 */ /*@	 @ public behavior	 @	 @ post size() == 0;	 @*/  public BlockingFifoList(){  }  /**	 * See superclass.	 */	public synchronized void push(Object object) {	  super.push(object);	  notify();  }  /**   * See superclass.   * Will block until the list is non-empty.   */ /*@	 @ also public behavior	 @	 @ pre true;	 @*/  public synchronized Object pop() {		// While loop in case an InterruptedException is thrown		// while there is no object available yet.		// MVDMVDMVD: Shouldn't the exception be thrown to the		// caller ?	  while(isEmpty()) {	    try {		    wait();	    } 			catch (InterruptedException ie) {	    }	  }	  return super.pop();  }  /**    * See superclass.    */  public synchronized Object getFirst() {	  while (isEmpty()) {		try {			wait();		} catch (InterruptedException ie) {		}	  }	  return super.getFirst();  }    /**   * See superclass/   */  public synchronized void clear() {	  super.clear();  }	/**	 * See superclass.	 */	public synchronized int size() {		return super.size();	}	/**	  * See superclass.	  */	public synchronized int nbExplicitOccurrences(Object item) {		return super.nbExplicitOccurrences(item);	}}/* * <copyright>Copyright (C) 1997-2001. This software is copyrighted by  * the people and entities mentioned after the "@author" tags above, on  * behalf of the JUTIL.ORG Project. The copyright is dated by the dates  * after the "@date" tags above. All rights reserved. * This software is published under the terms of the JUTIL.ORG Software * License version 1.1 or later, a copy of which has been included with * this distribution in the LICENSE file, which can also be found at * http://org-jutil.sourceforge.net/LICENSE. This software is distributed  * WITHOUT ANY WARRANTY; without even the implied warranty of  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  * See the JUTIL.ORG Software License for more details. For more information, * please see http://org-jutil.sourceforge.net/</copyright> */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -