On May 31, Mark Wielaard wrote:
> Hi,
> 
> I checked in some of my little bugfixes and some new classes that were not
> yet checked in. Here is the changelog:
>     [...]
>     * java/util/Timer.java: new 1.3 class
>     * java/util/TimerTask.java: new 1.3 class
> 
> I would appreciate it if someone looked over these files to see if I
> did anything stupid.
> 
> I did have a strange problem with java.util.Timer with gcj. Sometimes I
> would get java.lang.IllegalMonitorStateException when testing it.
> Could someone with a newer or cvs version of gcj (I have 2.95.2) try the
> attached program with the java.util.Timer[Task] classes from cvs
> (you have to compile them with jikes first to get class files)
> and tell if you still get a IllegalMonitorException. I hope it is a bug
> in gcj, but it might also very well be a bug in my code.

I had a looked through these classes, to see if this is caused by an
obvious bug, but all notify() and wait() calls are synchronized as
they should.  The classes look good, great work!

But I think there is a race in Scheduler.run().  IMHO the queue
monitor must be kept between queue.top() and queue.sleep().  Otherwise
a task may be enqueued in between and the scheduler wouldn't notice
since the notify() comes before the sleep().

I also think notifyAll() is "more correct" than notify(), but that
doesn't really matter, since the scheduler is the only one that may be
waiting.

  Jochen


Reply via email to