From fb300c873102a669767ddc9f624efd0353b77b34 Mon Sep 17 00:00:00 2001 From: Christian Basler Date: Mon, 19 Oct 2015 15:08:11 +0200 Subject: [PATCH] Fixed possible ConcurrentModificationException --- .../ch/dissem/bitmessage/ports/MultiThreadedPOWEngine.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/domain/src/main/java/ch/dissem/bitmessage/ports/MultiThreadedPOWEngine.java b/domain/src/main/java/ch/dissem/bitmessage/ports/MultiThreadedPOWEngine.java index 3c4572e..a4f02f5 100644 --- a/domain/src/main/java/ch/dissem/bitmessage/ports/MultiThreadedPOWEngine.java +++ b/domain/src/main/java/ch/dissem/bitmessage/ports/MultiThreadedPOWEngine.java @@ -43,6 +43,10 @@ public class MultiThreadedPOWEngine implements ProofOfWorkEngine { for (int i = 0; i < cores; i++) { Worker w = new Worker(workers, (byte) cores, i, initialHash, target); workers.add(w); + } + for (Worker w : workers) { + // Doing this in the previous loop might cause a ConcurrentModificationException in the worker + // if a worker finds a nonce while new ones are still being added. w.start(); } for (Worker w : workers) {