private void scheduleEmptyRequests(long delay) {
        assertLocked();

        if (delay < 0L) {
            throw(new IllegalArgumentException(
                    "Empty request delay must be >= 0 (was: " + delay + ")"));
        }

        if (!isWorking()) {
            return;
        }
        
        // If we're already scheduled, do nothing.
        if (emptyRequestFuture != null)
            return;

        // Schedule the transmission
        if (LOG.isLoggable(Level.FINER)) {
            LOG.finer("Scheduling empty request in " + delay + "ms");
        }
        try {
            // If we're scheduling an empty request while the session is paused, then
            // we're scheduling the request that will wake us up from pause.  If not,
            // then sendEmptyRequests should do nothing if it's run when the session
            // is paused.
            final boolean wasPaused = sessionPaused;
            Runnable emptyRequestRunnable = new Runnable() {
                public void run() { sendEmptyRequests(wasPaused); }
            };

            emptyRequestFuture = schedExec.schedule(emptyRequestRunnable,
                    delay, TimeUnit.MILLISECONDS);
        } catch (RejectedExecutionException rex) {
            LOG.log(Level.FINEST, "Could not schedule empty request", rex);
        }
    }