public inbox for frysk@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: frysk@sourceware.org
Cc: Tim Moore <timoore@redhat.com>
Subject: Re: [SCM]  master: Avoid spurious waits in CountDownLatch.await
Date: Fri, 23 Nov 2007 11:15:00 -0000	[thread overview]
Message-ID: <1195816497.2981.13.camel@dijkstra.wildebeest.org> (raw)
In-Reply-To: <1195810857.2981.6.camel@dijkstra.wildebeest.org>

Hi Tim,

On Fri, 2007-11-23 at 10:40 +0100, Mark Wielaard wrote:
> On Thu, 2007-11-22 at 20:53 +0000, moore@sourceware.org wrote:
> >     2007-11-22  Tim Moore  <timoore@redhat.com>
> >     
> >     	* CountDownLatch.java (await): Loop to avoid spurious wakeup.
> 
> Using wait() and notify() are such a pain :{
> Good you caught this one.
> Using higher order concurrent primitives is good.

I did find a bug though (just by running make check in frysk-core).
await need to be synchronized if you call wait() on this otherwise you
will get "current thread not owner" exceptions.

You might want to look into the public domain implementation of
CountDownLatch maybe to double check you got all the corner cases:
http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/CountDownLatch.java

Cheers,

Mark

diff --git a/frysk-core/frysk/util/CountDownLatch.java
b/frysk-core/frysk/util/C
index b191782..f9d548f 100644
--- a/frysk-core/frysk/util/CountDownLatch.java
+++ b/frysk-core/frysk/util/CountDownLatch.java
@@ -53,7 +53,7 @@ public class CountDownLatch {
         this.count = count;
     }
 
-    public void await()
+    public synchronized void await()
         throws InterruptedException {
         while (count != 0) {
             try {


      reply	other threads:[~2007-11-23 11:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20071122205327.10260.qmail@sourceware.org>
2007-11-23  9:41 ` Mark Wielaard
2007-11-23 11:15   ` Mark Wielaard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1195816497.2981.13.camel@dijkstra.wildebeest.org \
    --to=mark@klomp.org \
    --cc=frysk@sourceware.org \
    --cc=timoore@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).