Possible duplicate: need-help-returning-object-in-thread-run-method
Hello. I have a class implementing runnable and I have a List, storing Threads instantiated with
The concurrency library supports this well. Note: If your task throws an Exception, the Future will hold this and throw a wrapping exception when you call get()
ExecutorService executor = Executors.newSingleThreadedExecutor();
Future future = executor.submit(new Callable() {
public String call() {
return "world";
}
});
String result = future.get();