### Question:
TimeoutWatcher extends Thread { public void update() { synchronized (this) { this.mLastUpdate = System.currentTimeMillis(); notify(); } } TimeoutWatcher(long inTimeout); void update(); @Override void run(); abstract void timeoutHandling(); void quit();  }### Answer:
@Test public void testUpdate() throws InterruptedException { final int[] count = new int[1]; count[0] = 0; final TimeoutWatcher theWatcher = new TimeoutWatcher(500) { @Override public void timeoutHandling() { count[0]++; } }; try { theWatcher.start(); Thread.sleep(250); theWatcher.update(); Thread.sleep(300); Assert.assertEquals(0, count[0]); } finally { theWatcher.quit(); } }