Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Michael Rauscher" Subject: Re: Drawing problem Message-ID: X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <8dYGh.272017$IL1.11129@newsfe13.lga> References: <8dYGh.272017$IL1.11129@newsfe13.lga> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 36 Date: Wed, 27 Apr 2011 15:31:31 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918291 96.60.20.240 (Wed, 27 Apr 2011 10:31:31 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:31:31 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1128 To: comp.lang.java.gui Knute Johnson wrote: >> So: Are there any guarantees that the EDT paint operation draws a >> BufferedImage that is in a state as it was before any Graphics >> (created via the BufferedImage) method was started that has not yet >> finished? > > If you don't call repaint() until you are done drawing on it I doubt it. The underlying system might cause a repaint, too. > If you queued a repaint() from another thread while you were in the > process of doing a draw I don't think you could guarantee where in the > draw you would be. If multiple threads kept multiple copies of the same > BufferedImage object then I think you could have a situation where you > draw on your copy and the other thread doesn't see it yet. I'm not > really clear on when that can happen but synchronizing the code will > certainly prevent that. In reality I don't think it will ever be a > problem. I used the EDT to serialize subsequent calls to Graphics-methods to prevent synchronizing. This way it's guaranteed that there's no drawXXX method running while paintComponent draws the image. But you're right. I can't imagine a situation in which it would be a real problem if the Graphics-method was called from a non EDT-thread. Thanks for clarifying this topic. Bye Michael --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24