final int serverTimeout = getStopTimeout() * 1000; if (serverTimeout > 0) { Thread thread = new Thread("Server Stop Timeout") { public void run() { try { Thread.sleep(serverTimeout); if (!timer.alreadyDone) { timer.timeout = true; // notify waiter synchronized (mutex) { if (Trace.FINEST) { Trace.trace(Trace.STRING_FINEST, "stop notify timeout"); } mutex.notifyAll(); } } } catch (Exception e) { if (Trace.SEVERE) { Trace.trace(Trace.STRING_SEVERE, "Error notifying server stop timeout", e); } } } }; thread.setDaemon(true); thread.start();