Use the Java 8 thread API.
Using allMatch
boolean allEmpty = aMap.values()
.stream()
.allMatch(opt -> !opt.isPresent());
Or using noneMatch
boolean allEmpty = aMap.values()
.stream()
.noneMatch(Optional::isPresent);
An important thing to note from the documentation is that both methods are "short circuits in terminal operations"
This is a terminal short circuit operation.
, , noneMatch allMatch, .