ChangeWatcher implements Runnable { public ChangeWatcher(ChangedList changedList, ChangeHandler handler, long watchFrequency) { this.changedList = changedList; this.handler = handler; this.watchFrequency = watchFrequency; this.status = StatusManager.getInstance(); continueWatch = true; } ChangeWatcher(ChangedList changedList,
                         ChangeHandler handler,
                         long watchFrequency); void run(); void endWatch();  }
@Test public void testChangeWatcher() throws Exception { ChangeWatcher changeWatcher = new ChangeWatcher(changedList, new TestHandler(), 100); new Thread(changeWatcher).start(); changes = 0; changedList.addChangedFile(new File("test-0")); Thread.sleep(200); assertEquals(1, changes); changes = 0; int changedFiles = 10; for (int i = 0; i < changedFiles; i++) { changedList.addChangedFile(new File("test-file-" + i)); } Thread.sleep(200); assertEquals(changedFiles, changes); changes = 0; changeWatcher.endWatch(); changedList.addChangedFile(new File("test-3")); Thread.sleep(200); assertEquals(0, changes); }