X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fxdcc%2Fcore%2FCore.java;h=cce13fe7eef28d7b5ae7d197192755f5170436cc;hb=d1fad6e229a7f6cc709ae2eaefe25394151436e2;hp=1b45c6af4aa52f17cb22c6d9a3fdac5b8b7d42c7;hpb=f8b1b38d714ac20b94867919582cce31ef7b807c;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/xdcc/core/Core.java b/src/main/java/net/pterodactylus/xdcc/core/Core.java index 1b45c6a..cce13fe 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,15 @@ 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. */ + } + } + if (!isRunning()) { + break; } /* find channels that should be monitored but are not. */ @@ -408,7 +414,10 @@ public class Core extends AbstractExecutionThreadService { } @Override - protected void shutDown() { + protected void triggerShutdown() { + synchronized (syncObject) { + syncObject.notifyAll(); + } } //