Java executors: how to be notified, without blocking, when a task completes?
Define a callback interface to receive whatever parameters you want to pass along in the completion notification. Then invoke it at the end of the task. You could even write a general wrapper for Runnable tasks, and submit these to ExecutorService. Or, see below for a mechanism built into Java 8. class CallbackTask implements Runnable … Read more