I'd like to fire many one-off async CompletableFutures, like so:
for (Job job : jobs) {
CompletableFuture.supplyAsync(() -> job.process())
.whenComplete(this::doSomething);
}
Ideally these CompletableFutures could be garbage collected after whenComplete
has finished. But is there a risk they are collected beforehand, since I'm not storing a reference?