public class PasswordCracker { // dies ist der laut Angabe bekannte Hashwert des Passworts public static final String HASH = "ef937752f7348a964445f60857009f881983a6af"; public static void main(String[] args) { int numProcs = Runtime.getRuntime().availableProcessors(); Thread[] workers = new Thread[numProcs]; Synchronizer sync = new Synchronizer(HASH); for (int i = 0; i < numProcs; i++) { workers[i] = new Thread(new PasswordCrackerThread(sync, rangeBound(numProcs, i), rangeBound(numProcs, i + 1) - 1)); workers[i].start(); } synchronized (sync) { while (! sync.hasSolution()) { try { sync.wait(); } catch (InterruptedException e) {} } } for (Thread w : workers) w.interrupt(); System.out.println("Guessed this password: " + sync.getSolution()); System.exit(0); } public static long rangeBound(int n, int i) { long upperBound = (long) 1e8; return n == i ? upperBound + 1 : (upperBound / n) * i; } }