@Trivial
    private void performAction(Runnable action, boolean addToQueue) {
        ExecutorService exec = executorService.getService();

        if (exec == null) {
            // If we can't find the executor service, we have to run it in place.
            action.run();
        } else {
            // If we can find the executor service, we'll add the action to the queue.
            // If the actionFuture is null (no pending actions) and the configFuture is null (no
            // pending configuration updates), we'll submit the actionsRunner to the executor
            // service to drain the queue
            //
            // configFuture is used to avoid bouncing the endpoint multiple times because of a
            // single configuration update.
            //
            // actionFuture is only set to a non-null value by kicking off the executor service here.
            // actionsRunner syncs on actionQueue, so we can't add any new actions while we are
            // draining the queue. When the queue is empty, actionFuture is explicitly set to null.
            //
            // Long story short, it prevents us from kicking off multiple executors which could run in
            // random order.
            if (addToQueue) {
                synchronized (actionQueue) {
                    actionQueue.add(action);
                    if ((actionFuture == null) && (configFuture == null)) {
                        actionFuture = exec.submit(actionsRunner);
                    }
                }
            } else {
                // Schedule immediately
                exec.submit(action);
            }
        }
    }
@ Trivial private void performAction ( Runnable action , boolean addToQueue ) { ExecutorService exec = executorService . getService ( ) ; if ( exec == null ) { action . run ( ) ; } else { if ( addToQueue ) { synchronized ( actionQueue ) { actionQueue . add ( action ) ; if ( ( actionFuture == null ) && ( configFuture == null ) ) { actionFuture = exec . submit ( actionsRunner ) ; } } } else { exec . submit ( action ) ; } } }
Schedule an activity to run off the SCR action thread,
if the ExecutorService is available

@param action Runnable action to execute
@param addToQueue Set to false if the action should be scheduled independently of the actionQueue