private void scheduleTask(final DeferredActionsQueue queue, final Runnable task) {
    myTaskQueue.add(task);
    myExecutor.execute(() -> {
      final List<Runnable> currentTasks = new ArrayList<>(MAX_TASKS_TO_PROCESS_AT_ONCE);
      if (myTaskQueue.drainTo(currentTasks, MAX_TASKS_TO_PROCESS_AT_ONCE) > 0) {
        // there is a requirement that these activities must be run from the swing thread
        // will be blocking one of pooled threads here, which is ok
        try {
          SwingUtilities.invokeAndWait(() -> {
            for (Runnable task1 : currentTasks) {
              try {
                queue.addLast(task1);
              }
              catch (Throwable e) {
                LOG.info(e);
              }
            }
          });
        }
        catch (Throwable e) {
          LOG.info("Task rejected: " + currentTasks, e);
        }
      }
    });
  }
private void scheduleTask(final DeferredActionsQueue queue, final Runnable task)