問題文
A task has to compute a value, hand that value back to the code that started it, and it may also report a checked failure. Which interface fits the task, and how does it reach an executor?
選択肢
- Callable, because its method returns a value and is declared to throw a checked exception, and an instance of it is passed to the submit method of the executor
- Runnable, because an executor takes that interface for its work, so the value has to be kept in a field of the task object and read from there afterwards
- Runnable, because its method hands a value back through the Future that submit returns, and a checked exception may be thrown from inside its body as well
- Callable, because its method returns a value that the caller wants, and an instance of it is passed to the execute method of the executor