Here are a few issues. Firstly:
return () -> { Random random = new Random(System.currentTimeMillis()); return random.nextInt(); };
The execution can be so fast (I can easily reproduce it) that it will return the same value all the time.
I would suggest you remove this millis as a minimum:
private static Callable<Integer> randomInt() { return () -> { Random random = new Random(); int x = random.nextInt(100); System.out.println(x); return x; }; }
Or it's even better to use ThreadLocalRandom.current().nextInt(100)
I also changed nextInt to return to within [0.. 100] , because nextInt could return a negative value and assume that you are returning 50 negative values, and then your max will be zero (default value) from biggestInt ; which is obviously wrong.
And then your sequential stream and inside each map operation you block until you finish Future.get . This way your forEach is executed in a single thread.
source share