diff options
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/concurrent/Channel.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/library/scala/concurrent/Channel.scala b/src/library/scala/concurrent/Channel.scala index 865d0187f6..588deb9830 100644 --- a/src/library/scala/concurrent/Channel.scala +++ b/src/library/scala/concurrent/Channel.scala @@ -35,8 +35,12 @@ class Channel[A] { } def read: A = synchronized { - while (null == written.next) { - nreaders += 1; wait(); nreaders -= 1 + while (written.next == null) { + try { + nreaders += 1 + wait() + } + finally nreaders -= 1 } val x = written.elem written = written.next |