Created
July 3, 2012 06:53
-
-
Save raymondtay/3038150 to your computer and use it in GitHub Desktop.
chained_lazy_vals
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object LazyValDeadLock extends App { | |
println((new Z).Y) | |
} | |
class Z { | |
lazy val X = 0 | |
lazy val Y = { | |
for(i <- 0 until 2 par) yield { | |
println(i) | |
X | |
} | |
} | |
} | |
/* | |
public scala.collection.parallel.immutable.ParSeq<java.lang.Object> Y(); | |
Code: | |
stack=5, locals=2, args_size=1 | |
0: aload_0 | |
1: getfield #16 // Field bitmap$0:I | |
4: iconst_2 | |
5: iand | |
6: iconst_0 | |
7: if_icmpne 80 | |
10: aload_0 | |
11: dup | |
12: astore_1 | |
13: monitorenter // <------- Main thread owns the lock now | |
14: aload_0 | |
15: getfield #16 // Field bitmap$0:I | |
18: iconst_2 | |
19: iand | |
20: iconst_0 | |
21: if_icmpne 74 | |
24: aload_0 | |
25: getstatic #31 // Field scala/Predef$.MODULE$:Lscala/Predef$; | |
28: iconst_0 | |
29: invokevirtual #35 // Method scala/Predef$.intWrapper:(I)Lscala/runtime/RichInt; | |
32: iconst_2 | |
33: invokevirtual #41 // Method scala/runtime/RichInt.until:(I)Lscala/collection/immutable/Range; | |
36: invokevirtual #47 // Method scala/collection/immutable/Range.par:()Lscala/collection/parallel/immutable/ParRange; <------ threads are started independent from object 'Z' | |
39: new #49 // class Z$$anonfun$Y$1 | |
42: dup | |
43: aload_0 | |
44: invokespecial #53 // Method Z$$anonfun$Y$1."<init>":(LZ;)V | |
47: getstatic #58 // Field scala/collection/parallel/immutable/ParSeq$.MODULE$:Lscala/collection/parallel/immutable/ParSeq$; | |
50: invokevirtual #62 // Method scala/collection/parallel/immutable/ParSeq$.canBuildFrom:()Lscala/collection/generic/CanCombineFrom; | |
53: invokeinterface #68, 3 // InterfaceMethod scala/collection/parallel/ParIterableLike.map:(Lscala/Function1;Lscala/collection/generic/CanBuildFrom;)Ljava/lang/Object; | |
58: checkcast #70 // class scala/collection/parallel/immutable/ParSeq | |
61: putfield #72 // Field Y:Lscala/collection/parallel/immutable/ParSeq; | |
64: aload_0 | |
65: aload_0 | |
66: getfield #16 // Field bitmap$0:I | |
69: iconst_2 | |
70: ior | |
71: putfield #16 // Field bitmap$0:I | |
74: getstatic #24 // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit; | |
77: pop | |
78: aload_1 | |
79: monitorexit | |
80: aload_0 | |
81: getfield #72 // Field Y:Lscala/collection/parallel/immutable/ParSeq; | |
84: areturn | |
85: aload_1 | |
86: monitorexit | |
87: athrow */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment