Answer the question
In order to leave comments, you need to log in
Why doesn't ExecutorService require shutdown in junit?
Good afternoon.
If using ExecutorService in main method, then shutdown must be used to terminate the program
public static void main(String[] args) {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.submit(() -> Utils.sleepSeconds(1));
System.out.println("Done");
executorService.shutdown();
}
@org.junit.jupiter.api.Test
public void test() {
ExecutorService executorService = Executors.newCachedThreadPool();
executorService.submit(() -> Utils.sleepSeconds(1));
System.out.println("Done");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question