From cc56343a75297fa39b3d215804b6145ef00ff1ed Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 19 Jan 2016 12:03:36 +0100 Subject: EiP 10.2 --- ws2015/eip/blaetter/10/2/Synchronizer.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ws2015/eip/blaetter/10/2/Synchronizer.java (limited to 'ws2015/eip/blaetter/10/2/Synchronizer.java') diff --git a/ws2015/eip/blaetter/10/2/Synchronizer.java b/ws2015/eip/blaetter/10/2/Synchronizer.java new file mode 100644 index 0000000..5efb127 --- /dev/null +++ b/ws2015/eip/blaetter/10/2/Synchronizer.java @@ -0,0 +1,22 @@ +public class Synchronizer { + public final String targetHash; + private Long solution = null; + + public Synchronizer(String hash) { targetHash = hash; } + + public synchronized void setSolution(long password) + { + solution = password; + this.notifyAll(); + } + + public synchronized long getSolution() + { + return solution; + } + + public synchronized boolean hasSolution() + { + return (solution != null); + } +} -- cgit v1.2.3