Thursday, 5 September 2013

Fire and forget with java.util.concurrent

Fire and forget with java.util.concurrent

How to go about implementing a "fire and forget" behavior with
java.util.concurrency? I tried:
ExecutorService executor = Executors.newSingleThreadExecutor();
public void push(Callable<Boolean> task) {
Future<Boolean> future = executor.submit(task);
future.get(timeout, timeoutUnit);
}
but the get() is blocking until completion. The push() caller is not
interested in the result of the task.

No comments:

Post a Comment