Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: javax.swing.Timer blocking program termination Date: Wed, 15 Jul 2015 01:16:09 +0000 (UTC) Organization: A noiseless patient Spider Lines: 36 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 15 Jul 2015 01:16:09 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="15204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ik1WtQCGB0ScxPC+JlNmknL2QQCZGUzE=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:JoqIdnreTgDBY/v7nyj5pJf9ZkQ= Xref: csiph.com comp.lang.java.programmer:32030 On Tue, 14 Jul 2015 15:08:11 -0700, Knute Johnson wrote: > That's one of the issues, the timer doesn't run on the EDT, it just > schedules its work on the EDT. > Yes, I saw that from Jeff's dumps. > "Although all Timers perform their waiting using a single, shared thread > (created by the first Timer object that executes), the action event > handlers for Timers execute on another thread -- the event-dispatching > thread." > OK. > It's not clear to me what "executes" is either, does that mean start() > is called on a timer or a timer has reached the initial delay and called > one of the event handlers? > 'execute' could well mean that there's a single ticker loop that increments the counters in all running Timers. That would be fairly efficient with them all on the same thread. And with intervals specified in mS, there should typically be plenty of time within a tick to run the two threads (timer and action) one after the other, so there shouldn't be any locking or synchronising clashes between them. [*] [*] However, the timer interval can be specified as < 1 mS, i.e. as fast as possible, so synchronization would be needed to handle that case, but even so it probably adds very little overhead in the general case where the timer interval is >= 1 and so the two sewquential thread invocations have completed before the tick interval expires. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |