code: public void prepareShutdown(int seconds, GracefulCallback cb)
     {
        shutdown.set(true);
  
        if (gracefulCallback == null) 
           gracefulCallback = cb;
  
        if (seconds > 0)
        {
           if (scheduledGraceful == null)
           {
              if (scheduledExecutorService == null)
                 scheduledExecutorService = Executors.newScheduledThreadPool(1);
  
              scheduledGraceful =
                 scheduledExecutorService.schedule(new WorkManagerShutdown(this), seconds, TimeUnit.SECONDS);
           }
        }
        else
        {
           synchronized (activeWorkWrappers)
           {
              if (activeWorkWrappers.isEmpty())
                 shutdown();
           }
        }
     }
docs: {@inheritDoc}