diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2010-06-11 14:20:58 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2010-06-11 14:20:58 +0000 |
commit | 5791355fe2e5b3f4cdb166f1550d504ac710f953 (patch) | |
tree | 626b6b8f95576564f82b242d84a2bfc524eafeff /test/files | |
parent | daeca9f379813a966d16b9707b5bf047e76c26e0 (diff) | |
download | scala-5791355fe2e5b3f4cdb166f1550d504ac710f953.tar.gz scala-5791355fe2e5b3f4cdb166f1550d504ac710f953.tar.bz2 scala-5791355fe2e5b3f4cdb166f1550d504ac710f953.zip |
Merged revisions 22206 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r22206 | dragos | 2010-06-09 17:49:53 +0200 (Wed, 09 Jun 2010) | 3 lines
Make local lazy values thread-safe. A local lazy val (defined inside
a method) is now guaranteed to be initialized at most once, even when
accessed from different threads. Closes #3007, review by odersky.
........
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/lazy-concurrent.check | 1 | ||||
-rw-r--r-- | test/files/run/lazy-concurrent.scala | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/files/run/lazy-concurrent.check b/test/files/run/lazy-concurrent.check new file mode 100644 index 0000000000..33cff9d4f8 --- /dev/null +++ b/test/files/run/lazy-concurrent.check @@ -0,0 +1 @@ +Initializing singleton. diff --git a/test/files/run/lazy-concurrent.scala b/test/files/run/lazy-concurrent.scala new file mode 100644 index 0000000000..4699ed6a15 --- /dev/null +++ b/test/files/run/lazy-concurrent.scala @@ -0,0 +1,17 @@ +object Test { + def main(args: Array[String]) { + class Singleton { + val field = () + println("Initializing singleton.") + } + lazy val Singleton = new Singleton + + var i = 0 + while (i < 4) { + new Thread(new Runnable { + def run = Singleton.field + }).start + i += 1 + } + } +} |