X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fnet%2Fpterodactylus%2Ffcp%2Fhighlevel%2FHighLevelCallback.java;h=7dc55dfc90aa753f80f5567d176fd3c82ac39227;hb=bf0b6fe3af98f1c31895190bc54d017b623acd2e;hp=ac448a640c1d849c0fb7fbe643729521dc91b4b2;hpb=16353715c279d8b535b7aabb287764e591788c92;p=jFCPlib.git diff --git a/src/net/pterodactylus/fcp/highlevel/HighLevelCallback.java b/src/net/pterodactylus/fcp/highlevel/HighLevelCallback.java index ac448a6..7dc55df 100644 --- a/src/net/pterodactylus/fcp/highlevel/HighLevelCallback.java +++ b/src/net/pterodactylus/fcp/highlevel/HighLevelCallback.java @@ -30,7 +30,6 @@ import java.util.List; * @param * The type of the high-level operation result * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - * @version $Id$ */ public class HighLevelCallback { @@ -84,15 +83,17 @@ public class HighLevelCallback { } /** - * Notifies all listeners that the result of the operation is now known. + * Notifies all listeners that the result of the operation is now known. As + * soon as a listener was notified it will be removed from the list of + * listeners! * * @see HighLevelCallbackListener#gotResult(HighLevelCallback) */ private synchronized void fireGotResult() { for (HighLevelCallbackListener highLevelCallbackListener: highLevelCallbackListeners) { - highLevelCallbackListeners.remove(highLevelCallbackListener); highLevelCallbackListener.gotResult(this); } + highLevelCallbackListeners.clear(); } /** @@ -133,7 +134,7 @@ public class HighLevelCallback { */ public R getResult(long waitTime) throws InterruptedException { synchronized (syncObject) { - if (!resultComplete) { + while (!resultComplete) { syncObject.wait(waitTime); } return result; @@ -161,7 +162,7 @@ public class HighLevelCallback { return; } resultComplete = true; - syncObject.notify(); + syncObject.notifyAll(); } fireGotResult(); }