Hello forum veterans,
I need a small help in understanding this CompletableFuture. I am learning this topic for my understanding.
As you can see, I first generate some random integer list. And then I try to find out max, min and near to 100 element in that list. And these three tasks should happen in parallel.
Sample Output:
In main, Start: 12:25:47.949939800
Generate: start,
thread name: ForkJoinPool.commonPool-worker-1
Generated List: [63, 55, 74, 76, 86, 35, 13, 33, 73, 29]
Generate: stop
findMax: ForkJoinPool.commonPool-worker-1 : 2022-11-26T12:25:47.973199
findMin: ForkJoinPool.commonPool-worker-2 : 2022-11-26T12:25:47.974763600
findNear100: ForkJoinPool.commonPool-worker-3 : 2022-11-26T12:25:47.975773900
Found the nearest of 100: 86
In main, End: 12:25:47.975773900
Question: Why are other methods not printing anything ?
My observation: If I remove the delay, it simply works fine like below: But why ?
In main, Start: 12:30:01.922193700
Generate: start, thread name: ForkJoinPool.commonPool-worker-1
Generated List: [79, 33, 63, 19, 20, 73, 35, 28, 55, 85]
Generate: stop
findMax: ForkJoinPool.commonPool-worker-1 : 2022-11-26T12:30:01.944750800
findMin: ForkJoinPool.commonPool-worker-2 : 2022-11-26T12:30:01.946752400
findNear100: ForkJoinPool.commonPool-worker-3 : 2022-11-26T12:30:01.946752400
Found the nearest of 100: 85
In main, End: 12:30:01.947536400
Found min of list: 19
Found max of list: 85
Regards,
Ranagal