From cf0ba5267e5ae852c9384562f1674e87c47c0715 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Mon, 17 Nov 2014 22:14:32 +0100 Subject: [PATCH] Use separate object for syncing the shutdown. --- src/main/java/net/pterodactylus/xdcc/core/Core.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index 1b45c6a..7355283 100644 --- a/src/main/java/net/pterodactylus/xdcc/core/Core.java +++ b/src/main/java/net/pterodactylus/xdcc/core/Core.java @@ -105,6 +105,7 @@ public class Core extends AbstractExecutionThreadService { /** The logger. */ private static final Logger logger = Logger.getLogger(Core.class.getName()); + private final Object syncObject = new Object(); /** The event bus. */ private final EventBus eventBus; private final ConnectionFactory connectionFactory; @@ -376,10 +377,12 @@ public class Core extends AbstractExecutionThreadService { @Override protected void run() throws Exception { while (isRunning()) { - try { - Thread.sleep(TimeUnit.MINUTES.toMillis(1)); - } catch (InterruptedException ie1) { - /* ignore. */ + synchronized (syncObject) { + try { + syncObject.wait(TimeUnit.MINUTES.toMillis(1)); + } catch (InterruptedException ie1) { + /* ignore. */ + } } /* find channels that should be monitored but are not. */ @@ -409,6 +412,9 @@ public class Core extends AbstractExecutionThreadService { @Override protected void shutDown() { + synchronized (syncObject) { + syncObject.notifyAll(); + } } // -- 2.7.4