我經歷this環節,這裏coiunting信號執行給定爲:如何實現信號
public class CountingSemaphore {
private int signals = 0;
public synchronized void take() {
this.signals++;
this.notify();
}
public synchronized void release() throws InterruptedException{
while(this.signals == 0) wait();
this.signals--;
}
}
我不能夠得到那個。在take()方法中,通知被調用,這將使其他線程進入該部分。不應該在take方法中等待。請幫助我理解。
感謝
Jayendra
爲什麼? JDK已經包含了一個。 – 2015-03-02 10:27:21