-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
parallel collections + object initialization = hang #8119
Comments
Imported From: https://issues.scala-lang.org/browse/SI-8119?orig=1 |
@som-snytt said (edited on Jan 7, 2014 4:10:41 AM UTC): object Foreacher {
val n = 0
val m = List(1).par.foreach(_ => n)
def main(args: Array[String]): Unit = println("Hello, all")
} I guess the foreach is kicked off from the static initializer of the class and blocks on the par result, which is blocked in turn because it references the static module. Of course, the REPL-specific part is the code wrapper. Put it in braces to localize it. |
@SethTisue said: For whatever it's worth, I encountered this while pasting in code from a blog post titled "More Benefits of Scala in CS1" (http://dynamicsofprogramming.blogspot.com/2013/12/more-benefits-of-scala-in-cs1.html). I wouldn't want to have to explain/defend this to a beginner. |
@som-snytt said: apm@mara:~$ scalam -Yrepl-class-based
Welcome to Scala version 2.11.0-M7 (OpenJDK 64-Bit Server VM, Java 1.7.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> val n = 0; for(i <- List(1).par) n
n: Int = 0 |
@SethTisue said: |
@som-snytt said: |
@SethTisue said: |
I double-checked that it doesn't hang in the 2.13.2-bin-b1550dd REPL |
This little poison pill:
hangs the REPL in 2.9.3, 2.10.3, and 2.11.0-M7.
-Yrepl-sync doesn't help.
The collection type doesn't matter (List, Range, Vector, whatever).
Accessing n in the body is necessary.
Using semicolon to put it all on one line is necessary.
The text was updated successfully, but these errors were encountered: