Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.gui Subject: Re: a tight game loop in Swing Date: Fri, 8 Jun 2012 12:28:52 -0700 (PDT) Organization: http://groups.google.com Lines: 25 Message-ID: <3cf3e02b-ee01-42b9-a287-5b2a476f0fb7@googlegroups.com> References: <01353eab-26e6-442c-9bf1-38ccf92b19ad@googlegroups.com> NNTP-Posting-Host: 69.28.149.29 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1339184189 21395 127.0.0.1 (8 Jun 2012 19:36:29 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 8 Jun 2012 19:36:29 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.28.149.29; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Received-Bytes: 2142 Xref: csiph.com comp.lang.java.gui:5175 Daniel Pitts wrote: > On 6/6/12 11:58 PM, Lew wrote: > > I am curious what motivated the choice of 'volatile'. > > > > In my own case I will sometimes speculatively use 'volatile' to mark > > fields not essential to state despite that the class does not implement > > 'Serializable'. While this violates the rigid rule prohibiting > > superfluity, I aver that the marker aids reasoning about the state in > > such cases. > > > > This doesn't seem to be that. > > > Volatile has nothing to do with Serializable. Perhaps you're having a > moment of confusing volatile with transient? Volatile is necessary when > you want to force a happens-before relationship to reads/writes to a > field. It also guarantees the you won't have a situation where writes > aren't flushed to main memory before the next attempted read. > > In other words, it is one safe way to publish a value across threads. Duhy. My foolishness. -- Lew