### Question:
ShutdownService { public Hook createHook(Thread thread) { thread.setDaemon(true); Hook retVal = new Hook(thread); hooks.add(retVal); return retVal; } ShutdownService(); Hook createHook(Thread thread);  }### Answer:
@Test public void testCreateHook() { Hook hook = instance.createHook(thread); assertNotNull(hook); List<Hook> hooks = instance.getHooks(); assertEquals(1, hooks.size()); assertEquals(hook, hooks.get(0)); }
@Test public void testRun() throws InterruptedException { Hook hook = instance.createHook(thread); assertTrue(hook.keepRunning()); instance.run(); assertFalse(hook.keepRunning()); }