ARTICLE AD BOX
in this answer notes that
parallelStream uses the fork/join common pool which is an Executor, [..]
Thus, when I want to replace a piece of code, using parallelStream(), what is the best practice to replace it with a Executor, i.e., more precisely
try (var executor = Executors.WHICH_METHOD()) { // <- which method to choose? }Moreover, I want to do parallelization of a request, i.e., invoking and destroying each time a try-with-resources seems to come with a bit of overhead.
Is it good practice to hold an ExecutorService as private field, e.g.
@Controller public class Foo { private static final ExecutorService EXECUTOR = Executors.WHICH_METHOD() // <-- which method to choose? // implementation }