@Test
  public void testShutdownWorksWhileChoresAreExecuting() throws InterruptedException {
    final int period = 100;
    final int sleep = 5 * period;
    ScheduledChore slowChore1 = new SleepingChore("sc1", period, sleep);
    ScheduledChore slowChore2 = new SleepingChore("sc2", period, sleep);
    ScheduledChore slowChore3 = new SleepingChore("sc3", period, sleep);
    assertTrue(service.scheduleChore(slowChore1));
    assertTrue(service.scheduleChore(slowChore2));
    assertTrue(service.scheduleChore(slowChore3));

    Thread.sleep(sleep / 2);
    shutdownService(service);

    assertFalse(slowChore1.isScheduled());
    assertFalse(slowChore2.isScheduled());
    assertFalse(slowChore3.isScheduled());
    assertTrue(service.isShutdown());

    Thread.sleep(5);
    assertTrue(service.isTerminated());
  }
ChoreServices should never have a core pool size that exceeds the number of chores that have
been scheduled with the service. For example, if 4 ScheduledChores are scheduled with a
ChoreService, the number of threads in the ChoreService's core pool should never exceed 4
hbase-common/src/test/java/org/apache/hadoop/hbase/TestChoreService.java