$ java MapConcurrentDemo      (JDK 25)
mapConcurrent(4, ...) results, completion order reversed: [10, 20, 30, 40]
CHECK ok   : mapConcurrent output preserves encounter order [10,20,30,40] even though task 1 finishes last
mapConcurrent(2, ...) over 8 tasks, peak concurrent in-flight = 2
CHECK ok   : all 8 tasks completed
CHECK ok   : peak in-flight never exceeded maxConcurrency=2, measured peak=2
CHECK ok   : the cap is actually reached, not just respected -- measured peak=2
VirtualThread[#38]/runnable@ForkJoinPool-1-worker-2 virtual=true
VirtualThread[#39]/runnable@ForkJoinPool-1-worker-2 virtual=true
VirtualThread[#40]/runnable@ForkJoinPool-1-worker-2 virtual=true
VirtualThread[#41]/runnable@ForkJoinPool-1-worker-2 virtual=true
VirtualThread[#42]/runnable@ForkJoinPool-1-worker-2 virtual=true
VirtualThread[#37]/runnable@ForkJoinPool-1-worker-1 virtual=true
CHECK ok   : every mapConcurrent worker thread reports isVirtual() == true
CHECK ok   : 6 elements produced 6 distinct virtual threads -- one per element, not a shared pool
mapConcurrent propagated: boom at element 3 after 901ms
CHECK ok   : the failure only surfaced after 901ms -- mapConcurrent waited for the other 4 in-flight tasks, it did not cancel them
exit=0
