private void startProcessing() {
    LOG.assertTrue(Thread.holdsLock(myQueue));

    if (isProcessing || !myStarted) {
      return;
    }
    isProcessing = true;
    Pair<T, ModalityState> pair = myQueue.removeFirst();
    T item = pair.getFirst();
    Runnable runnable = () -> {
      if (myDeathCondition.value(null)) {
        finishProcessing(false);
        return;
      }
      runSafely(() -> myProcessor.accept(item, (Runnable)() -> finishProcessing(true)));
    };
    Application application = ApplicationManager.getApplication();
    switch (myThreadToUse) {
      case AWT -> {
        ModalityState state = pair.getSecond();
        if (state == null) {
          application.invokeLater(runnable);
        }
        else {
          application.invokeLater(runnable, state);
        }
      }
      case POOLED -> {
        if (application == null) {
          SwingUtilities.invokeLater(runnable);
        }
        else {
          AppJavaExecutorUtil.executeOnPooledIoThread(runnable);
        }
      }
    }
  }
private void startProcessing()