Name (print *CLEARLY*): _________________________________________________


Student ID (print *CLEARLY*; 1 digit per underline): _____ _____ _____ _____ _____ _____

CSE 231s Quiz 17: ExecutorService

Interface Future<V>

V get()
Waits if necessary for the computation to complete, and then retrieves its result.

Interface ExecutorService

<T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
Executes the given tasks, returning a list of Futures holding their status and results when all complete. Future.isDone() is true for each element of the returned list. 
<T> Future<T> submit(Callable<T> task)
Submits a value-returning task for execution and returns a Future representing the pending results of the task. The Future's get method will return the task's result upon successful completion.

If you would like to immediately block waiting for a task, you can use constructions of the form result = exec.submit(aCallable).get();

Given the documentation above, write pseudocode for doItYourselfInvokeAll using executor.submit(task) and future.get():

<T> List<Future<T>> doItYourselfInvokeAll(ExecutorService executor, Collection<? extends Callable<T>> tasks) {