@SuppressWarnings({ "rawtypes", "unchecked" }) @Test @Ignore public void testRun() throws Exception { DatabaseConnector<?> dbc = Mockito.mock(DatabaseConnector.class); StatusWriter sw = Mockito.mock(StatusWriter.class); Mockito.when(dbc.getStatusWriter()).thenReturn(sw); StatusUpdater su = new StatusUpdater(dbc, 1); Mockito.verify(sw, Mockito.never()).increment(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt()); su.start(); Thread.sleep(500); su.interrupt(); Mockito.verify(sw, Mockito.atLeast(2)).increment(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt()); Thread.sleep(500); Mockito.verifyNoMoreInteractions(sw); }
public void run() { while (!isInterrupted()) { try { saveStatus(); Thread.sleep(interval); } catch (InterruptedException e) { saveStatus(); interrupt(); } } }
StatusUpdater extends Thread { public void run() { while (!isInterrupted()) { try { saveStatus(); Thread.sleep(interval); } catch (InterruptedException e) { saveStatus(); interrupt(); } } } }
StatusUpdater extends Thread { public void run() { while (!isInterrupted()) { try { saveStatus(); Thread.sleep(interval); } catch (InterruptedException e) { saveStatus(); interrupt(); } } } StatusUpdater(DatabaseConnector<?> connector);  StatusUpdater(DatabaseConnector<?> connector, int updateIntervalMs); }
StatusUpdater extends Thread { public void run() { while (!isInterrupted()) { try { saveStatus(); Thread.sleep(interval); } catch (InterruptedException e) { saveStatus(); interrupt(); } } } StatusUpdater(DatabaseConnector<?> connector);  StatusUpdater(DatabaseConnector<?> connector, int updateIntervalMs); void setUpdateInterval(int updateIntervalMs); int getUpdateInterval(); synchronized void addProcessed(int toAdd); synchronized void addFailed(int toAdd); synchronized void addDiscarded(int toAdd); void run(); void saveStatus(); }
StatusUpdater extends Thread { public void run() { while (!isInterrupted()) { try { saveStatus(); Thread.sleep(interval); } catch (InterruptedException e) { saveStatus(); interrupt(); } } } StatusUpdater(DatabaseConnector<?> connector);  StatusUpdater(DatabaseConnector<?> connector, int updateIntervalMs); void setUpdateInterval(int updateIntervalMs); int getUpdateInterval(); synchronized void addProcessed(int toAdd); synchronized void addFailed(int toAdd); synchronized void addDiscarded(int toAdd); void run(); void saveStatus();  }