Customizing parallelStream's thread pool

Introduction By default, ForkJoinPool creates a thread for each processor, and parallelStream will use this shared thread pool to submit tasks if not specified. So how do we handle a specific situation where we want to use a custom ForkJoinPool? Common operations If we want to do an addition from 1 to 1000, we can use parallel stream like this. List<Integer> integerList= IntStream.range(1,1000).boxed().collect(Collectors.toList()); ForkJoinPool customThreadPool = new ForkJoinPool(4); Integer total= integerList.