/** Notifies the scheduler that a thread has been interrupted and is finishing its work. */
 private void notifyThreadLeaving() {
   profileCollectorHandle.notifyThreadRemoved();
   // NOTE: we're not yet trying to adapt the number of threads being
   // used, so we assume that threads are only lost when the system
   // wants to shutdown...in practice, this should look at some
   // threshold and see if another consumer needs to be created
   if (threadCount.decrementAndGet() == 0) {
     logger.log(Level.CONFIG, "No more threads are consuming tasks");
     shutdown();
   }
 }