Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Daniele Futtorovic Newsgroups: comp.lang.java.programmer Subject: Re: The invokeLater loop Date: Fri, 10 May 2013 23:50:26 +0200 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 10 May 2013 21:46:46 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="f6ca6bb52c0933e86b8a17e90bd81433"; logging-data="2738"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qxpRwzQYju3u+bI9t/OqM" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: Cancel-Lock: sha1:L6Aq7tZPCVIaVyYApKxTmJ2QsTw= Xref: csiph.com comp.lang.java.programmer:23999 On 10/05/2013 21:40, Stefan Ram allegedly wrote: > Daniel Pitts writes: >> It is a good way to eat up CPU cycles if you don't want to have your CPU >> go idle. Also known as a laptop warmer. > > Say, I am writing an implementation of the »Game Of Life«. I have an > endless main loop whose contents updates to the next generation. > > I want to have a sequence like: > > - calculate next generation > - update screen > - calculate next generation > - update screeen > - calculate next generation > - ... > > I think that I can do this by calculating the next generation and > updating the screen in »paintComponent« and then »invokingLater« > paintComponent or requesting a screen update which indirectly will > call »paintComponent« again. This will give the sequence above. Not sure I get this. If you are performing non-UI-related computations in your "Object" (I second Daniel's remarks on your choice of nomenclature, btw), then these will happen on the EDT. But they should actually be happening /off/ the EDT. So it seems to me either you are busying the EDT and lagging the app, or it's really just a laptop warmer. Perhaps another example would be useful. -- DF.