-
-
Save kasramp/c01e89446b1a07c2e041046c5b6daf7a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.UUID; | |
import java.util.concurrent.Callable; | |
import java.util.concurrent.ForkJoinPool; | |
import java.util.stream.IntStream; | |
public class Application { | |
private void processLargeDataSet() { | |
List<String> largeDataset = getLargeDataset(); | |
ForkJoinPool customThreadPool = new ForkJoinPool(5); | |
customThreadPool.submit(() -> largeDataset.parallelStream().forEach(System.out::println)); | |
customThreadPool.shutdownNow(); | |
} | |
private List<String> getLargeDataset() { | |
List<String> largeDataset = new ArrayList<>(); | |
IntStream.range(0, Integer.MAX_VALUE).forEach(i -> { | |
largeDataset.add(UUID.randomUUID().toString()); | |
}); | |
return largeDataset; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment