Question 3
Back to Exercise
The program below does not compile. Which statement correctly describes the problem?
import java.util.concurrent.ExecutorService;
public class Main {
public static void main(String[] args) {
ExecutorService pool = new ExecutorService();
pool.submit(() -> System.out.println("hi"));
}
}
- A submit needs a Callable
- B ExecutorService is an interface; create one with a factory such as Executors.newFixedThreadPool(4) Correct
- C ExecutorService must be imported from java.lang
- D pool must be final
Correct Answer: Option B
javac: "ExecutorService is abstract; cannot be instantiated".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!