We use callable<V>
and Future<V>
to receive the result of a terminated thread from a thread pool. We should call get()
to receive the returned result. My problem is: it is not event driven. Is there any framework to get result like SIGCHLD
for child processes in C?
I want something like this:(the thread pool will call this function when each thread in the pool finished the job)
public void fetchResult(Thread t, Runnable r, Future<Integer> result) {
Integer x = result.get();
/* handle x */
/* also we have Thread and Runnable object that has terminated */
}