classpath
[Top][All Lists]
Advanced

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

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


From: Joao Victor
Subject: Nasty problem in javax.swing.Timer.restart()
Date: Thu, 10 Nov 2005 16:33:38 +0000

Yesterday i posted this bug about tooltips appearing too fast:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24763

However, i was taking a look at the ToolTipManager.java source, and
noticed the logic apparently is already there.

So i started investigating the problem, and found something. In a few
words: ToolTipManager uses javax.swing.Timer to schedule the
appearance of the tooltip, as you may know. The problem happens
because when it calls Timer.restart(), restart() starts a new thread
before _really_ stopping the previous one.

It calls:
stop()
start()

However, because of the whole nature of wait/notifys/threads, when
that start() is executed, stop() has only notified the other thread -
it doesn't mean the other thread _really_ stopped.

So, you end up with 2 threads in the 'start' state. One of them will
block at the 'wait()' code, the other just moves on and shows the
tooltip -- too early.

The attached patch i'm sending apparently fixes this problem. I don't
know if it's the best way to fix it, though; take a look at what it
does and see if it's useful.

Cheers,
J.V.

Attachment: Timer-jv.patch
Description: Text Data


reply via email to

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