Scala noob here:
val pv = (1 to 100).toArray.par
Now I want to apply a map function to this parallel collection pv
pv.map(_ * 2)
However the above operation hangs. Any reason why?
Using Scala version 2.12.4
on a Mac OS X (High Sierra)
Scala noob here:
val pv = (1 to 100).toArray.par
Now I want to apply a map function to this parallel collection pv
pv.map(_ * 2)
However the above operation hangs. Any reason why?
Using Scala version 2.12.4
on a Mac OS X (High Sierra)
Seems this is caused by static initializer deadlock, see:
https://github.com/scala/scala-parallel-collections/issues/34
This issue point out in the repl, when create a parallel collection, repl will generate a wraper for it, when init, it will cause dead lock.
and it also can be reproduce in program from the:
https://github.com/scala/bug/issues/8119
object Foreacher {
val n = 0
val m = List(1).par.foreach(_ => n)
def main(args: Array[String]): Unit = println("Hello, all")
}