@Test public void testRun() throws Exception { final CountDownLatch waitLatch = new CountDownLatch(1); final ClientRunnable clientRunnable = new ClientRunnable() { @Override protected void customRun() throws InterruptedException { waitLatch.countDown(); } }; final CountDownLatch latch = new CountDownLatch(1); new Thread(new Runnable() { public void run() { try { waitLatch.await(10, TimeUnit.SECONDS); synchronized (clientRunnable.monitor) { clientRunnable.running = false; clientRunnable.monitor.wait(); } latch.countDown(); } catch (InterruptedException e) { } } }).start(); clientRunnable.run(); assertTrue("Not notified", latch.await(10, TimeUnit.SECONDS)); }
public void run() { try { while (running) { try { customRun(); } catch (InterruptedException e) { return; } } } finally { terminate(); } }
ClientRunnable implements Runnable { public void run() { try { while (running) { try { customRun(); } catch (InterruptedException e) { return; } } } finally { terminate(); } } }
ClientRunnable implements Runnable { public void run() { try { while (running) { try { customRun(); } catch (InterruptedException e) { return; } } } finally { terminate(); } }  }
ClientRunnable implements Runnable { public void run() { try { while (running) { try { customRun(); } catch (InterruptedException e) { return; } } } finally { terminate(); } }  void run(); void shutdown(); }
ClientRunnable implements Runnable { public void run() { try { while (running) { try { customRun(); } catch (InterruptedException e) { return; } } } finally { terminate(); } }  void run(); void shutdown();  }