@Test
  public void testChangingChoreServices() throws InterruptedException {
    final int period = 100;
    final int sleepTime = 10;
    ChoreService anotherService = new ChoreService(name.getMethodName() + "_2");
    ScheduledChore chore = new DoNothingChore("sample", period);

    try {
      assertFalse(chore.isScheduled());
      assertFalse(service.isChoreScheduled(chore));
      assertFalse(anotherService.isChoreScheduled(chore));
      assertTrue(chore.getChoreService() == null);

      service.scheduleChore(chore);
      Thread.sleep(sleepTime);
      assertTrue(chore.isScheduled());
      assertTrue(service.isChoreScheduled(chore));
      assertFalse(anotherService.isChoreScheduled(chore));
      assertFalse(chore.getChoreService() == null);

      anotherService.scheduleChore(chore);
      Thread.sleep(sleepTime);
      assertTrue(chore.isScheduled());
      assertFalse(service.isChoreScheduled(chore));
      assertTrue(anotherService.isChoreScheduled(chore));
      assertFalse(chore.getChoreService() == null);

      chore.cancel();
      assertFalse(chore.isScheduled());
      assertFalse(service.isChoreScheduled(chore));
      assertFalse(anotherService.isChoreScheduled(chore));
      assertTrue(chore.getChoreService() == null);
    } finally {
      shutdownService(anotherService);
    }
  }
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