### Question:
Watchdog implements Closeable { public void arm() { setEnabled(true); } Watchdog(long defaultTimeoutMS, Runnable timeoutMethod); @Override void finalize(); @Override void close(); boolean isEnabled(); void arm(); void disarm();  }### Answer:
@Test(timeout = 20000) public void test() { long watchdogTimeoutMS = 10; long watchdogMaxIntrMS = watchdogTimeoutMS * 3; AtomicBoolean inerruptedFlag = new AtomicBoolean(); Thread testThread = Thread.currentThread(); try (Watchdog watchDog = new Watchdog(watchdogTimeoutMS, () -> { Msg.trace(this, "" + System.currentTimeMillis() + ": Interrupting the test thread..."); inerruptedFlag.set(true); testThread.interrupt(); })) { for (int i = 0; i < 10; i++) { inerruptedFlag.set(false); watchDog.arm(); long start = System.currentTimeMillis(); try { Thread.sleep(DEFAULT_WAIT_TIMEOUT); fail(System.currentTimeMillis() + ": Watchdog did not fire"); } catch (InterruptedException e) { assertTrue("" + System.currentTimeMillis() + ": Sleep was interrupted, but not by watchdog", inerruptedFlag.get()); long elapsed = System.currentTimeMillis() - start; Msg.trace(this, System.currentTimeMillis() + ": Watchdog fired in: " + elapsed + "ms, max target is: " + watchdogMaxIntrMS + "ms"); } } } }