Future<Void> (@NotNull Collection<? extends File> files) { List<File> tempFiles = new ArrayList<>(); for (File file : files) { File tempFile = renameToTempFileOrDelete(file); if (tempFile != null) { tempFiles.add(tempFile); } } return tempFiles.isEmpty() ? CompletableFuture.completedFuture(null) : AppExecutorUtil.getAppExecutorService().submit(() -> { Thread currentThread = Thread.currentThread(); int priority = currentThread.getPriority(); currentThread.setPriority(Thread.MIN_PRIORITY); try { for (File tempFile : tempFiles) { delete(tempFile); } } finally { currentThread.setPriority(priority); } return null; }); }