void (final List<? extends Printable> printables) { if (printables.isEmpty()) return; final ArrayList<Printable> currentPrintables = new ArrayList<>(printables); //move out from AWT thread final Runnable request = () -> { synchronized (myFileLock) { for (final Printable printable : currentPrintables) { printable.printOn(myPrinter); } myPrinter.close(); } printOutputFile(currentPrintables); }; invokeInAlarm(request, ApplicationManager.getApplication().isUnitTestMode()); }