@Test public void testWaitForRunning() { ServiceThread testServiceThread = startTestServiceThread(); testServiceThread.waitForRunning(1000); assertEquals(false, testServiceThread.hasNotified.get()); assertEquals(1, testServiceThread.waitPoint.getCount()); testServiceThread.wakeup(); assertEquals(true, testServiceThread.hasNotified.get()); assertEquals(0, testServiceThread.waitPoint.getCount()); testServiceThread.waitForRunning(1000); assertEquals(false, testServiceThread.hasNotified.get()); assertEquals(0, testServiceThread.waitPoint.getCount()); testServiceThread.waitForRunning(1000); assertEquals(false, testServiceThread.hasNotified.get()); assertEquals(1, testServiceThread.waitPoint.getCount()); }
protected void waitForRunning(long interval) { if (hasNotified.compareAndSet(true, false)) { this.onWaitEnd(); return; } waitPoint.reset(); try { waitPoint.await(interval, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Interrupted", e); } finally { hasNotified.set(false); this.onWaitEnd(); } }
ServiceThread implements Runnable { protected void waitForRunning(long interval) { if (hasNotified.compareAndSet(true, false)) { this.onWaitEnd(); return; } waitPoint.reset(); try { waitPoint.await(interval, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Interrupted", e); } finally { hasNotified.set(false); this.onWaitEnd(); } } }
ServiceThread implements Runnable { protected void waitForRunning(long interval) { if (hasNotified.compareAndSet(true, false)) { this.onWaitEnd(); return; } waitPoint.reset(); try { waitPoint.await(interval, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Interrupted", e); } finally { hasNotified.set(false); this.onWaitEnd(); } } ServiceThread(); }
ServiceThread implements Runnable { protected void waitForRunning(long interval) { if (hasNotified.compareAndSet(true, false)) { this.onWaitEnd(); return; } waitPoint.reset(); try { waitPoint.await(interval, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Interrupted", e); } finally { hasNotified.set(false); this.onWaitEnd(); } } ServiceThread(); abstract String getServiceName(); void start(); void shutdown(); void shutdown(final boolean interrupt); long getJointime(); @Deprecated void stop(); @Deprecated void stop(final boolean interrupt); void makeStop(); void wakeup(); boolean isStopped(); boolean isDaemon(); void setDaemon(boolean daemon); }
ServiceThread implements Runnable { protected void waitForRunning(long interval) { if (hasNotified.compareAndSet(true, false)) { this.onWaitEnd(); return; } waitPoint.reset(); try { waitPoint.await(interval, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { log.error("Interrupted", e); } finally { hasNotified.set(false); this.onWaitEnd(); } } ServiceThread(); abstract String getServiceName(); void start(); void shutdown(); void shutdown(final boolean interrupt); long getJointime(); @Deprecated void stop(); @Deprecated void stop(final boolean interrupt); void makeStop(); void wakeup(); boolean isStopped(); boolean isDaemon(); void setDaemon(boolean daemon);  }