condition.java

来自「java jdk 1.4的源码」· Java 代码 · 共 54 行

JAVA
54
字号
/* * @(#)Condition.java	1.39 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.corba.se.internal.orbutil;//// Traditional Condition variables, unbound to any instance or class.//							KGH April 95final public class Condition {    public Condition() {    }    public void wait(Lock lock) {        synchronized (this) {	    lock.unlock();	    boolean ok = false;	    while (!ok) {	        try {		    super.wait();		    ok = true;	        } catch (InterruptedException ex) {		    // Eat it and loop again.  The user doesn't care how		    // long we wait.	        }	    }	}	lock.lock();    }    public void wait(Lock lock, int timeout)	throws InterruptedException {	synchronized (this) {	    lock.unlock();	    super.wait(timeout);	}	lock.lock();    }    public synchronized void signal() {	super.notify();    }    public synchronized void signalAll() {	super.notifyAll();    }}

⌨️ 快捷键说明

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