private void stopExecutor() {
        Log.debug("Stopping executor service...");
        /*
         * This method gets called as part of the Component#shutdown() routine.
         * If that method gets called, the component has already been removed
         * from the routing tables. We don't need to worry about new packets to
         * arrive - there won't be any.
         */
        if (objectName != null) {
            JMXManager.tryUnregister(objectName);
            objectName = null;
        }
        executor.shutdown();
        try {
            if (!executor.awaitTermination(2, TimeUnit.SECONDS)) {
                Log.debug("Forcing a shutdown for the executor service (after a two-second timeout has elapsed...");
                executor.shutdownNow();
                // Note that if any IQ request stanzas had been scheduled, they
                // MUST be responded to with an error here. A list of tasks that
                // have never been commenced by the executor is returned by the
                // #shutdownNow() method of the ExecutorService.
            }
        } catch (InterruptedException e) {
            // ignore, as we're shutting down anyway.
        }
    }
Shuts down the executor by dropping all tasks from the queue. This method
will allow the executor to finish operations on running tasks for a
period of two seconds. After that, tasks are forcefully stopped.
<p>
The order in which the various shutdown routines of the executor are
called, is:
<ol>
<li>{@link ExecutorService#shutdown()}</li>
<li>{@link ExecutorService#awaitTermination(long, TimeUnit)} (two
seconds)</li>
<li>{@link ExecutorService#shutdownNow()}</li>
</ol>
xmppserver/src/main/java/org/jivesoftware/openfire/pep/IQPEPHandler.java