void stop() { if (timeoutThread == null) { return; } enabled = false; synchronized (sleepLock) { sleepLock.notifyAll(); } try { if (Thread.currentThread() != timeoutThread) { timeoutThread.join(); } timeoutThread = null; } catch (InterruptedException e) { throw new RuntimeException(e); } }