[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Nasty problem in javax.swing.Timer.restart()

From: Mark Wielaard
Subject: Re: Nasty problem in javax.swing.Timer.restart()
Date: Thu, 10 Nov 2005 20:29:29 +0100


On Thu, 2005-11-10 at 19:26 +0100, Meskauskas Audrius wrote:
> Thanks for idea. The problem seems real and the solution may work.

Yes, thanks Joao. I agree the problem is real. The queueLock is used for
multiple things that are not completely related (guarding the queue
variable and guarding Timer running status). But I am afraid we have to
do a more radical rewrite of this class. Reading some bits about how
swing Timers are used suggests that they should/can just use one Thread
for all Timers you create. And that makes sense since I assume swing
Timers are often used so creating/destroying a Thread each time a Timer
is instantiated might be a bit much overhead. We should then make this
Thread a daemon thread so when all other Threads stop the program
properly terminates. I believe our util Timer code is pretty much what
we want here. Util Timer uses a heap of TimerTasks to makes finding the
next task to fire O(1) and inserting new tasks O(logn). One Util Timer
can then be shared by all Swing Timers which just register TimerTasks
with it. But maybe I am over-engineering here (I wrote Util Timer, so I
am biased. I also introduced this bug in Swing Timer so I am also a bit

We clearly need more (mauve) tests for this class.



Attachment: signature.asc
Description: This is a digitally signed message part

reply via email to

[Prev in Thread] Current Thread [Next in Thread]