I have this code evaluated with Ammonite:
$ amm
Welcome to the Ammonite Repl 2.5.1 (Scala 2.13.8 Java 17.0.1)
@ import $ivy.`org.scala-lang.modules::scala-parallel-collections:1.0.4`
@ import scala.collection.parallel.CollectionConverters._
@ Seq(1,2).foreach { x => Thread sleep x*1000; println(s"Fin $x") };println("Fin")
Fin 1
Fin 2
Fin
It completes ok.
If I add the par
to parallelize, then it never finishes:
@ Seq(1,2).par.foreach { x => Thread sleep x*1000; println(s"Fin $x") };println("Fin")
Is this a bug? With Scala 2.12 I get the same behaviour.