3 ms·
I appreciate the cleverness of just adding AutoClosable to ExecutorService. But I definitely think returning a specific subclass/interface of ExecutorService wo
by kasperni 6y ago
I appreciate the cleverness of just adding AutoClosable to ExecutorService. But I definitely think returning a specific subclass/interface of ExecutorService would be a great help. I think at the expense of an extra class, something like this is a lot easier for people to wrap their head around:
try (Nursery n = Nursery.spawn()) {
n.submit(() -> foo());
n.submit(() -> bar());
}
try (Nursery n = Nursery.spawnWithDeadline(Instant)) {
...
try (Nursery nx = n.spawn()) {
nx.submit(() -> foo());
nx.submit(() -> bar());
}
...
}
...