void (Notification notification, Object __) { if (LowMemoryWatcher.notificationsSuppressed()) return; boolean memoryThreshold = MemoryNotificationInfo.MEMORY_THRESHOLD_EXCEEDED.equals(notification.getType()); boolean memoryCollectionThreshold = MemoryNotificationInfo.MEMORY_COLLECTION_THRESHOLD_EXCEEDED.equals(notification.getType()); if (memoryThreshold || memoryCollectionThreshold) { synchronized (myJanitor) { if (mySubmitted == null) { mySubmitted = myExecutorService.submit(() -> myJanitor.accept(memoryCollectionThreshold)); // maybe it's executed too fast or even synchronously if (mySubmitted.isDone()) { mySubmitted = null; } } } } }