<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8405107760807432973</id><updated>2012-01-29T15:22:24.845-08:00</updated><category term='C++'/><category term='Java libraries'/><category term='Scala'/><category term='Google Talks'/><category term='JVMTI'/><category term='Hotspot JVM'/><category term='Java Language'/><category term='Profiling'/><category term='Java Bytecode'/><category term='politics'/><category term='Garbage Collection'/><category term='Java Memory Model'/><category term='Volatile Keyword'/><category term='Java'/><category term='immutability'/><category term='OpenJDK'/><title type='text'>Java Concurrency (&amp;c)</title><subtitle type='html'>Jeremy Manson's blog, which goes into great detail either about concurrency in Java, or anything else that the author happens to feel is interesting or relevant to the target audience.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>55</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5459635207870933531</id><published>2011-06-03T08:14:00.000-07:00</published><updated>2011-06-13T21:55:48.409-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scala'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Garbage Collection'/><category scheme='http://www.blogger.com/atom/ns#' term='Java libraries'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Scala / Java Shootout</title><summary type='text'>I should probably comment on this paper from my colleague Robert Hundt, where he writes the same benchmark in Java, Scala, Go, Python and C++ (TL;DR here). Short version: Initially, C++ was faster than Scala, and Scala was faster than Java.  I volunteered to make some improvements, which ended up with the C++ and Java implementations being about the same speed.  Some C++ hackers then went and </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5459635207870933531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5459635207870933531' title='36 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5459635207870933531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5459635207870933531'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2011/06/scala-java-shootout.html' title='Scala / Java Shootout'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>36</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-714834987873739295</id><published>2011-05-13T09:40:00.000-07:00</published><updated>2011-05-13T09:42:06.217-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='Java libraries'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Language'/><title type='text'>Java Puzzlers@Google I/O</title><summary type='text'>Josh Bloch and I gave one of his Java Puzzlers talk at Google I/O this year. If you hate Java, you can waste a perfectly good hour listening to us make unfunny jokes at its expense.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/714834987873739295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=714834987873739295' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/714834987873739295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/714834987873739295'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2011/05/java-puzzlersgoogle-io.html' title='Java Puzzlers@Google I/O'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/wbp-3BJWsU8/default.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-8601546806388086991</id><published>2011-04-05T16:25:00.000-07:00</published><updated>2011-04-05T20:07:56.022-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='Garbage Collection'/><category scheme='http://www.blogger.com/atom/ns#' term='Hotspot JVM'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Cliff Click in "A JVM Does What?"</title><summary type='text'>Cliff Click gave a very good talk at Google last week.  For your viewing enjoyment:The slides are available here.(For those who watched it: The inventors of bytecode were in the audience.  I think he was just used to making that joke elsewhere.)</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/8601546806388086991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=8601546806388086991' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8601546806388086991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8601546806388086991'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2011/04/cliff-click-in-jvm-does-what.html' title='Cliff Click in &quot;A JVM Does What?&quot;'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://img.youtube.com/vi/uL2D3qzHtqY/default.jpg' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-8695271857614411381</id><published>2010-08-27T12:31:00.000-07:00</published><updated>2011-04-06T08:38:47.438-07:00</updated><title type='text'>JavaOne Talk Cancelled</title><summary type='text'>Because I am a Google employee, my talks are not happening.  Apologies to any interested parties.I'm going to try to give the talks in another venue, or at least to use the blog as a venue for some of the topics I wanted to cover.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/8695271857614411381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=8695271857614411381' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8695271857614411381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8695271857614411381'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2010/08/javaone-talk-cancelled.html' title='JavaOne Talk Cancelled'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7626460736810359038</id><published>2010-08-02T00:07:00.000-07:00</published><updated>2010-08-02T15:59:58.815-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JVMTI'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Hotspot JVM'/><category scheme='http://www.blogger.com/atom/ns#' term='Profiling'/><title type='text'>Why Many Profilers have Serious Problems (More on Profiling with Signals)</title><summary type='text'>This is a followon to a blog post I made in 2007 about using signal handling to profile Java apps.  I mentioned in another post why this might be a good idea, but I wanted to expand on the theme.Hiroshi Yamauchi and I are giving a talk at this year's JavaOne.  Part of this talk will be about our experiences writing profilers at Google, and in preparing for it, I realized my previous entry on this</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7626460736810359038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7626460736810359038' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7626460736810359038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7626460736810359038'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2010/07/why-many-profilers-have-serious.html' title='Why Many Profilers have Serious Problems (More on Profiling with Signals)'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-4747503688332712345</id><published>2010-02-07T23:56:00.000-08:00</published><updated>2010-02-08T00:30:49.098-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Garbage Collection'/><category scheme='http://www.blogger.com/atom/ns#' term='Hotspot JVM'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Garbage Collection, [Soft]References, Finalizers and the Memory Model (Part 2)</title><summary type='text'>In which I ramble on at greater length about finalizers and multithreading, as well as applying that discussion to SoftReferences.  Read Part 1 first.  It explains why finalizers are more multithreaded than you think, and why they, like all multithreaded code, aren't necessarily going to do what you think they should do.I mentioned in the last entry that a co-worker asked me a question about when</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/4747503688332712345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=4747503688332712345' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4747503688332712345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4747503688332712345'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2010/02/garbage-collection-softreferences.html' title='Garbage Collection, [Soft]References, Finalizers and the Memory Model (Part 2)'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-2489086152388866113</id><published>2010-01-31T23:39:00.000-08:00</published><updated>2010-02-03T14:24:17.333-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Garbage Collection'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Garbage Collection, References, Finalizers and the Memory Model (Part 1)</title><summary type='text'>A little while ago, I got asked a question about when an object is allowed to be collected.   It turns out that objects can be collected sooner than you think.  In this entry, I'll talk a little about that.When we were formulating the memory model, this question came up with finalizers.  Finalizers run in separate threads (usually they run in a dedicated finalizer thread).  As a result, we had to</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/2489086152388866113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=2489086152388866113' title='18 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2489086152388866113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2489086152388866113'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2010/01/garbage-collection-references.html' title='Garbage Collection, References, Finalizers and the Memory Model (Part 1)'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>18</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-6692901484020964609</id><published>2010-01-06T20:40:00.000-08:00</published><updated>2010-01-06T21:00:21.497-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Java libraries'/><title type='text'>A Note on the Thread (Un)safety of Format Classes</title><summary type='text'>I recently got a note on another blog post asking this question:I have a general question on the thread safety and this is not directly related with your blog. I would appreciate if you could post it on your blog. I have a class that has only one static method that accepts two string parameters and does some operation locally (as shown below). Do I need to synchronize this method?public class A {</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/6692901484020964609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=6692901484020964609' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/6692901484020964609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/6692901484020964609'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2010/01/note-on-thread-unsafety-of-format.html' title='A Note on the Thread (Un)safety of Format Classes'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>12</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-2428541233733768018</id><published>2009-12-10T15:52:00.001-08:00</published><updated>2009-12-14T11:26:55.635-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Bytecode'/><title type='text'>Allocation Instrumenter for Java</title><summary type='text'>In brief: We've open sourced a tool that allows you to provide a callback every time your program performs an allocation. The Java Allocation Instrumenter can be found here.  Give it a whirl, if you are interested.One thing that crops up a lot at my employer is the need to take an action on every allocation.  This can happen in a lot of different contexts:The programmer has a task, and wants to </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/2428541233733768018/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=2428541233733768018' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2428541233733768018'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2428541233733768018'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2009/12/allocation-instrumenter-for-java_10.html' title='Allocation Instrumenter for Java'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7620669917068654986</id><published>2009-09-07T22:56:00.000-07:00</published><updated>2010-08-11T16:56:35.337-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Hotspot JVM'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Cliff Click on Java-vs-C Performance</title><summary type='text'>Cliff Click has a terrific post on Java-vs-native-code performance.  Recommended.Cliff is the Chief JVM Architect at Azul Systems, was the lead designer behind Hotspot's server JIT compiler, and is an all-around smart guy.  His main drawback is that he (apparently) gets dragged into flamewars on YouTube's comment section.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7620669917068654986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7620669917068654986' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7620669917068654986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7620669917068654986'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2009/09/cliff-click-on-java-vs-c-performance.html' title='Cliff Click on Java-vs-C Performance'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-4434950048433636102</id><published>2009-07-07T23:23:00.000-07:00</published><updated>2010-07-02T00:28:29.981-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Garbage Collection'/><category scheme='http://www.blogger.com/atom/ns#' term='Hotspot JVM'/><title type='text'>How Hotspot Decides to Clear SoftReferences</title><summary type='text'>I got asked about this twice in one day, and I didn't know the answer, so I sat down and puzzled it out a bit.A SoftReference is a reference that the garbage collector can decide to clear if it is the only reference left to an object, and the GC decides (through some undefined process) that there is enough memory pressure to warrant clearing it.   SoftReferences are generally used to implement </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/4434950048433636102/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=4434950048433636102' title='21 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4434950048433636102'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4434950048433636102'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2009/07/how-hotspot-decides-to-clear_07.html' title='How Hotspot Decides to Clear SoftReferences'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>21</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5825384944681355315</id><published>2009-06-17T10:30:00.000-07:00</published><updated>2009-06-22T20:28:38.082-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Volatile Keyword'/><title type='text'>Volatile Arrays in Java</title><summary type='text'>I get asked a lot about how the volatile keyword interacts with arrays, so it is probably worth a blog post on the subject.Those of you who have read my posts on volatile (Volatile Fields and Synchronization, Volatile Does Not Mean Atomic and, most importantly, What Volatile Means in Java) will have a pretty good idea of what volatile means, but it is probably worth it to provide a reminder.  </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5825384944681355315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5825384944681355315' title='27 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5825384944681355315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5825384944681355315'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2009/06/volatile-arrays-in-java.html' title='Volatile Arrays in Java'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>27</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7903008255950247847</id><published>2009-06-09T00:38:00.000-07:00</published><updated>2009-06-09T00:42:07.075-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Welcome!</title><summary type='text'>Mailinator's Paul Tyma linked to me.  If you are following from that link, the relevant blog entry you are looking for is probably this one, specifically, the entry labeled "visibility".</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7903008255950247847/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7903008255950247847' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7903008255950247847'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7903008255950247847'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2009/06/welcome.html' title='Welcome!'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7274210031460416252</id><published>2009-04-04T13:56:00.000-07:00</published><updated>2009-04-05T17:13:34.670-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java libraries'/><title type='text'>Faster Logging with Faster Logger Classes</title><summary type='text'>Today, I'll discuss a little tweak I made to java.util.Logging that made my logging throughput double.  I want to use it as an illustration that it often isn't very difficult to improve the performance of concurrent code by doing things that are actually pretty easy to do.So, "I" have an application that is running a couple of hundred threads on an 8-core machine, and it wants to log about 2MB a </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7274210031460416252/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7274210031460416252' title='19 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7274210031460416252'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7274210031460416252'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2009/04/faster-logging-with-faster-logger.html' title='Faster Logging with Faster Logger Classes'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>19</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-4409028312241058369</id><published>2009-02-28T16:25:00.001-08:00</published><updated>2009-03-01T01:28:58.700-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Language'/><title type='text'>Small Language Changes for JDK7</title><summary type='text'>For those who haven't been paying attention, there is a new project from Sun to attract proposals for small language changes to JDK7.  Even in the first day of open calls for proposals, the entries have been very interesting:Strings in Switch, a proposal from Joe Darcy to be able to use Strings in switch statements.Automated Resource Blocks, a proposal from Josh Bloch to be able to say things </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/4409028312241058369/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=4409028312241058369' title='34 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4409028312241058369'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4409028312241058369'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2009/02/small-language-changes-for-jdk7.html' title='Small Language Changes for JDK7'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>34</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-2128551827505427746</id><published>2008-12-14T11:49:00.000-08:00</published><updated>2009-12-11T11:25:46.726-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Date-Race-Ful Lazy Initialization for Performance</title><summary type='text'>I was asked a question about benign data races in Java this week, so I thought I would take the opportunity to discuss one of the (only) approved patterns for benign races.  So, at the risk of encouraging bad behavior (don't use data races in your code!), I will discuss the canonical example of "benign races for performance improvement".  Also, I'll put in another plug for Josh Bloch's new </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/2128551827505427746/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=2128551827505427746' title='31 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2128551827505427746'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2128551827505427746'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/12/benign-data-races-in-java.html' title='Date-Race-Ful Lazy Initialization for Performance'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>31</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-4049319992855709183</id><published>2008-11-15T13:05:00.000-08:00</published><updated>2009-06-17T10:43:02.835-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Volatile Keyword'/><title type='text'>What Volatile Means in Java</title><summary type='text'>Today, I'm going to talk about what volatile means in Java.  I've sort-of covered this in other posts, such as my posting on the ++ operator, my post on double-checked locking and the like, but I've never really addressed it directly.First, you have to understand a little something about the Java memory model.  I've struggled a bit over the years to explain it briefly and well.  As of today, the </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/4049319992855709183/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=4049319992855709183' title='95 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4049319992855709183'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4049319992855709183'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/11/what-volatile-means-in-java.html' title='What Volatile Means in Java'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm4.static.flickr.com/3073/3035268779_f8a9dce89d_t.jpg' height='72' width='72'/><thr:total>95</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-3673933666557244245</id><published>2008-11-08T23:50:00.000-08:00</published><updated>2009-07-08T23:02:00.837-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='OpenJDK'/><title type='text'>G1 Garbage Collector in Latest OpenJDK Drop</title><summary type='text'>ETA:  The G1 collector is now in the latest JDK6 release, which you can download from Sun here.  You can enable it for testing with the flags -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC.  Original post follows.For those of you who are interested in tinkering with new garbage collectors, the "Garbage-first" G1 garbage collector is in the new JDK7 drop from OpenJDK.  I haven't tried it yet, but I</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/3673933666557244245/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=3673933666557244245' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3673933666557244245'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3673933666557244245'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/11/g1-garbage-collector-in-latest-openjdk.html' title='G1 Garbage Collector in Latest OpenJDK Drop'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7479919162436698411</id><published>2008-10-26T23:49:00.000-07:00</published><updated>2008-10-27T00:39:18.162-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='politics'/><title type='text'>A Brief Digression into Politics</title><summary type='text'>A plea for you to vote "No" on CA Proposition 8, and maintain the rights of same-sex couples in California.I really hate using this blog as a political forum.  I have a personal blog I use for that, read only by people who know me.  This blog should be expressly for computer-related topics.  I apologize to readers expecting me to talk about concurrency or APIs or anything else.  I apologize to </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7479919162436698411/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7479919162436698411' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7479919162436698411'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7479919162436698411'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/10/brief-digression-into-politics.html' title='A Brief Digression into Politics'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-9063054749363821</id><published>2008-08-24T01:30:00.000-07:00</published><updated>2008-09-13T12:29:57.519-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Don't Use StringBuffer!</title><summary type='text'>One thing I have noticed among Java API users is that some don't seem to know that there is a difference between StringBuffer and StringBuilder.  There is: StringBuffer is synchronized, and StringBuilder isn't.  (The same is true for Vector and ArrayList, as well as Hashtable and HashMap).  StringBuilder avoids extra locking operations, and therefore you should use it where possible.  That's not </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/9063054749363821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=9063054749363821' title='38 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/9063054749363821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/9063054749363821'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/08/dont-use-stringbuffer.html' title='Don&apos;t Use StringBuffer!'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>38</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-311017186748836706</id><published>2008-08-18T00:46:00.000-07:00</published><updated>2008-08-27T00:43:40.602-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='immutability'/><title type='text'>Top 3 Reasons Why Constructors are Worthless</title><summary type='text'>In my last post, I made an offhand reference to the fact that object constructors are worthless in Java.  I was asked why this is, so I thought I'd fill in the details.This topic is a little more well-understood by the developer community than some of the concurrency tidbits that I usually discuss.  People who use dependency injection toolkits like Guice and Spring's inversion of control tend to </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/311017186748836706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=311017186748836706' title='34 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/311017186748836706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/311017186748836706'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/08/top-3-reasons-why-constructors-are.html' title='Top 3 Reasons Why Constructors are Worthless'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>34</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-6908708708586919336</id><published>2008-07-21T00:26:00.000-07:00</published><updated>2008-08-27T00:43:59.911-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='immutability'/><title type='text'>Immutability in Java, Part 3: Deserialization and Reflection</title><summary type='text'>This time, I'll talk about deserialization, immutability and final fields.  I'll try to be a little shorter.I spent the last two posts on immutability (here and here) talking about what it takes to make an object's fields immutable.  This advice mostly boiled down to "it has to be final and set before the constructor ends".When you have deserialization, though, the fields can't be set before the </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/6908708708586919336/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=6908708708586919336' title='24 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/6908708708586919336'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/6908708708586919336'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/07/immutability-in-java-part-3.html' title='Immutability in Java, Part 3: Deserialization and Reflection'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>24</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5388898596594034828</id><published>2008-07-14T00:01:00.000-07:00</published><updated>2009-09-26T11:43:07.886-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='immutability'/><title type='text'>Immutability in Java, Part 2</title><summary type='text'>I'd like to talk a little more about what it takes to ensure thread-safe immutability in Java, following on from a (semi)recent post I made on the subject.The basic gist of that post was that if you make data immutable, then they can be shared between threads without additional synchronization.   I call this "thread-safe immutability".  In that post, I said this:Now, in common parlance, </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5388898596594034828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5388898596594034828' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5388898596594034828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5388898596594034828'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/07/immutability-in-java-part-2.html' title='Immutability in Java, Part 2'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-1918453820989643308</id><published>2008-05-23T00:53:00.000-07:00</published><updated>2009-06-17T10:43:36.647-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Volatile Keyword'/><title type='text'>Double Checked Locking</title><summary type='text'>I still get a lot of questions about whether double-checked locking works in Java, and I should probably post something to clear it up.  And I'll plug Josh Bloch's new book, too.Double Checked Locking is this idiom: // Broken -- Do Not Use!  class Foo {   private Helper helper = null;   public Helper getHelper() {     if (helper == null) {       synchronized(this) {         if (helper == null) {</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/1918453820989643308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=1918453820989643308' title='70 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1918453820989643308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1918453820989643308'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/05/double-checked-locking.html' title='Double Checked Locking'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>70</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5234338911301054671</id><published>2008-05-11T23:29:00.000-07:00</published><updated>2008-05-12T00:15:52.967-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Which Lock is Which?</title><summary type='text'>I was at JavaOne last week, and attended Bill Pugh's Defective Java talk.  Bill had an important point about what kind of locks you want to be using and what kind you don't, and that point is worth repeating.Bill is, with Dave Hovemeyer, the guy behind FindBugs, which everyone should be using religiously.  He was also my graduate advisor; we worked together on the new Java Memory Model.  If there</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5234338911301054671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5234338911301054671' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5234338911301054671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5234338911301054671'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/05/which-lock-is-which.html' title='Which Lock is Which?'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-2434464383084411603</id><published>2008-04-25T22:15:00.001-07:00</published><updated>2008-08-27T00:44:45.618-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='immutability'/><title type='text'>Immutability in Java</title><summary type='text'>Another topic that comes up again and again in questions that people ask me is, "How does immutability work in Java"?  Immutability is a godsend for concurrent programmers, because you don't have to do lots of sticky reasoning about what threads are updating what variables when, and you don't have to worry about cache thrashing, and you don't have to worry about all sorts of things.  When I write</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/2434464383084411603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=2434464383084411603' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2434464383084411603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2434464383084411603'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/04/immutability-in-java.html' title='Immutability in Java'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7364172135144045266</id><published>2008-03-06T22:55:00.000-08:00</published><updated>2008-03-06T22:57:41.929-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Talk on x86 Memory Model</title><summary type='text'>Rick Hudson gave a talk at Google about the new official memory model for the Intel x86 platform.  Good stuff, for memory model geeks.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7364172135144045266/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7364172135144045266' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7364172135144045266'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7364172135144045266'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/03/talk-on-x86-memory-model.html' title='Talk on x86 Memory Model'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-3073593779241558782</id><published>2008-03-05T23:35:00.000-08:00</published><updated>2009-07-08T23:19:35.620-07:00</updated><title type='text'>Java Performance Talk</title><summary type='text'>Paul Tyma and I gave a talk at SD West today on Java Performance Myths.  The big takeaway was this: Most of the things you think you know about Java performance are really hard to quantify.  Write the best code you can.  Profile it to find the bottlenecks.  Remove the bottlenecks.  Rinse and repeat.A couple of other takeaway points here:Don't forget to upgrade every so often.  JDK6, for example, </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/3073593779241558782/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=3073593779241558782' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3073593779241558782'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3073593779241558782'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/03/java-performance-talk.html' title='Java Performance Talk'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-4210861145124330887</id><published>2008-03-05T09:35:00.000-08:00</published><updated>2008-03-05T09:35:39.429-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Hotspot Garbage Collection</title><summary type='text'>Thought of the Day: The production version of Hotspot has 211 command line options for garbage collection.  Getting the right combination of options is hard.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/4210861145124330887/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=4210861145124330887' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4210861145124330887'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4210861145124330887'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2008/02/hotspot-garbage-collection.html' title='Hotspot Garbage Collection'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-3941444133852739217</id><published>2008-02-12T13:47:00.000-08:00</published><updated>2008-02-19T13:23:17.583-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Causality and the Java Memory Model</title><summary type='text'>NB: I started writing this last August, and sent it to a friend of mine for thoughts.  I just realized that he never got back to me on it, and I never posted it.  I don't much feel like editing it now, so here it is in its original gloryOkay, I know.  It is nearly impossible to read and understand the causality bits of the Java memory model.  That's all that stuff about "Executions and Causality </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/3941444133852739217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=3941444133852739217' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3941444133852739217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3941444133852739217'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/08/causality-and-java-memory-model.html' title='Causality and the Java Memory Model'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-3008391668363779215</id><published>2007-08-30T23:35:00.000-07:00</published><updated>2009-07-02T01:36:24.212-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Volatile Keyword'/><title type='text'>Atomicity, Visibility and Ordering</title><summary type='text'>(Note: I've cribbed this from my doctoral dissertation.  I tried to edit it heavily to ease up on the mangled academic syntax required by thesis committees, but I may have missed some / badly edited in places.  Let me know if there is something confusingly written or just plain confusing, and I'll try to untangle it.)There are these three concepts, you see.  And they are fundamental to correct </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/3008391668363779215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=3008391668363779215' title='28 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3008391668363779215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3008391668363779215'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/08/atomicity-visibility-and-ordering.html' title='Atomicity, Visibility and Ordering'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>28</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-3229058718882334780</id><published>2007-08-21T16:16:00.001-07:00</published><updated>2009-06-17T10:43:15.148-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Volatile Keyword'/><title type='text'>Volatile Does Not Mean Atomic!</title><summary type='text'>Here's a question I get a lot.  Is the following code snippet "thread safe"?volatile int v = 0;Thread 1:v++;Thread 2:v--;The question asks what the possible results of this code are; the questioners usually want the answer "v can only be 0 after this code is run".This isn't the way it works!  If you do an increment of a volatile integer, you are actually performing three separate operations:Read </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/3229058718882334780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=3229058718882334780' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3229058718882334780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3229058718882334780'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/08/volatile-does-not-mean-atomic.html' title='Volatile Does Not Mean Atomic!'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-417915258884658518</id><published>2007-08-14T00:49:00.000-07:00</published><updated>2007-08-14T00:56:29.246-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><title type='text'>Java Puzzlers at Google</title><summary type='text'>Those of you who attend JavaOne will know Josh Bloch, Neal Gafter and Bill Pugh's series of highly entertaining Java Puzzlers.  Now, for the first time, one of these talks is available to people who are not JavaOne attendees: Josh and Bill gave this year's Java Puzzlers talk at Google.I wouldn't dare spoil the fun by posting any of the puzzlers or their solutions (although Josh blows the surprise</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/417915258884658518/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=417915258884658518' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/417915258884658518'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/417915258884658518'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/08/java-puzzlers-at-google.html' title='Java Puzzlers at Google'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-3094751839180247290</id><published>2007-08-01T21:18:00.001-07:00</published><updated>2007-08-01T21:34:01.322-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><title type='text'>Mark Moir on Transactional Memory</title><summary type='text'>This is another one of those Google talks.  This time, it is Mark Moir talking about the transactional memory work he is doing at Sun.  It is very useful if you are interested in listening to a strong statement about building hybrid software / hardware transactional memory systems.As someone who has written papers on transactional memory systems, I am still unconvinced that they are the panacea </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/3094751839180247290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=3094751839180247290' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3094751839180247290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3094751839180247290'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/08/mark-moir-on-transactional-memory.html' title='Mark Moir on Transactional Memory'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-8784219788328942908</id><published>2007-06-25T23:31:00.000-07:00</published><updated>2007-06-26T11:15:50.290-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Signals and Java</title><summary type='text'>Ooookay.  You are now, presumably, fresh from reading the original post about using AsyncGetCallTrace and the more recent post about how to use SIGPROF in C++.  The next obvious question is...Can I Register a Signal Handler in Java?Um...  Kind of!There is an undocumented and unsupported interface called sun.misc.Signal present in most Java implementations.  For those of you who have downloaded </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/8784219788328942908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=8784219788328942908' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8784219788328942908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8784219788328942908'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/06/signals-and-java.html' title='Signals and Java'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-1620488417203695648</id><published>2007-06-25T22:02:00.000-07:00</published><updated>2007-06-25T23:58:29.708-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JVMTI'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>More about profiling with SIGPROF</title><summary type='text'>First, read this post about profiling with JVMTI and SIGPROF.A poster on that entry asked me to elaborate a little on exactly what happens when the timer goes off and the signal is raised.  In this post, I'll explain that in a little more detail.  First, I'll back up a little.Edited to add: Okay, I wrote this whole thing, and very, very briefly answered the actual question at the end.  So, if you</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/1620488417203695648/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=1620488417203695648' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1620488417203695648'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1620488417203695648'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/06/more-about-profiling-with-sigprof.html' title='More about profiling with SIGPROF'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-1024019203548249210</id><published>2007-06-09T11:39:00.001-07:00</published><updated>2007-06-09T12:29:04.153-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Answer to Weekend Multithreaded Puzzler</title><summary type='text'>This is the answer to the riddle posed in my earlier puzzler posting.  You should probably look at that question before looking at this answer.  I suppose I should call it something other than a puzzler, to avoid getting hit by Josh and Neal's angry team of vicious, snarling lawyers...This program certainly looks straightforward.  It just looks as if two threads are writing to two variables.  In </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/1024019203548249210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=1024019203548249210' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1024019203548249210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1024019203548249210'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/06/answer-to-weekend-multithreaded-puzzler.html' title='Answer to Weekend Multithreaded Puzzler'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5075720104924380209</id><published>2007-06-09T11:17:00.000-07:00</published><updated>2007-06-09T11:37:51.290-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Weekend Multithreaded Puzzler Fun!</title><summary type='text'>Although I didn't go this year, one of my favorite parts of JavaOne is always Josh Bloch and Neal Gafter's talk on Java Puzzlers.  (This year, Bill Pugh, my graduate advisor, stepped in for Neal.)  A puzzler is a short snippet of code which has unexpected results, usually because some language or API feature behaves in a strange way.  I enjoy them because I always think it is truly wonderful to </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5075720104924380209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5075720104924380209' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5075720104924380209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5075720104924380209'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/06/weekend-multithreaded-puzzler-fun.html' title='Weekend Multithreaded Puzzler Fun!'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7740031158442547655</id><published>2007-06-04T22:00:00.001-07:00</published><updated>2010-07-31T14:22:46.569-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JVMTI'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Hotspot JVM'/><category scheme='http://www.blogger.com/atom/ns#' term='Profiling'/><title type='text'>More thoughts on SIGPROF, JVMTI and stack traces</title><summary type='text'>This is a follow up from my previous post about profiling with SIGPROF and JVMTI.There are, in fact, a very large number of ways of getting stack traces out of a JVM.  If you send a system-dependent signal to your JVM process, it will spit out a stack dump of every currently live thread.  On Solaris and Linux, the signal is a SIGQUIT, which you can get by using kill -3 on the JVM PID (or the PID </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7740031158442547655/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7740031158442547655' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7740031158442547655'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7740031158442547655'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/06/more-thoughts-on-sigprof-jvmti-and.html' title='More thoughts on SIGPROF, JVMTI and stack traces'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-12242420740633363</id><published>2007-06-04T16:26:00.000-07:00</published><updated>2007-06-04T21:58:12.986-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ Threads</title><summary type='text'>There is a very good talk by Lawrence Crowl on the upcoming threading changes to C++.  I wrote a brief entry about his talk on C++0x (where they are hoping for x &lt; 10).  They have developed heavily on the work done for the Java model, so that they could resolve some of the C++ absurdities that inevitably occur.  Hans Boehm, who was heavily involved in the Java effort, has been leading the </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/12242420740633363/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=12242420740633363' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/12242420740633363'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/12242420740633363'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/06/c-threads.html' title='C++ Threads'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-4751208332054017038</id><published>2007-05-23T20:17:00.000-07:00</published><updated>2007-05-23T20:36:54.327-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Double-Checked Locking and the Problem with Wikipedia</title><summary type='text'>I love Wikipedia, I really do.  I use it for everything.  Well, not everything.  For example, if I want a really good piece of chocolate cake, I tend to use flour, sugar, butter, eggs, chocolate, and not Wikipedia at all.  For many things, however, Wikipedia cannot be surpassed.Imagine, then, my surprise when I found out that their page on Double-Checked Locking gave an example of a version of </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/4751208332054017038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=4751208332054017038' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4751208332054017038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/4751208332054017038'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/05/double-checked-locking-and-problem-with.html' title='Double-Checked Locking and the Problem with Wikipedia'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5370045468923715521</id><published>2007-05-14T16:22:00.000-07:00</published><updated>2010-07-31T14:22:26.522-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JVMTI'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Hotspot JVM'/><category scheme='http://www.blogger.com/atom/ns#' term='Profiling'/><title type='text'>Profiling with JVMTI/JVMPI, SIGPROF and AsyncGetCallTrace</title><summary type='text'>This post is not about the memory model, but, instead, is about being able to get, asynchronously, the stack trace of a currently executing thread out of Sun's Java VM.    Getting one synchronously is easy, of course.I was trying to profile some Java applications under Linux, and I wanted to use SIGPROF and JVMTI to find out what code was running at any given second.  This is just a posting to </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5370045468923715521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5370045468923715521' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5370045468923715521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5370045468923715521'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/05/profiling-with-jvmtijvmpi-sigprof-and.html' title='Profiling with JVMTI/JVMPI, SIGPROF and AsyncGetCallTrace'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5932804055591279629</id><published>2007-05-11T00:36:00.000-07:00</published><updated>2007-05-11T00:37:32.730-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><title type='text'>Google Talks</title><summary type='text'>By the way, gentle reader, in case you haven't noticed, I am running a series of talks at Google.All of them can be found here.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5932804055591279629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5932804055591279629' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5932804055591279629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5932804055591279629'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/05/google-talks.html' title='Google Talks'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-5549438606677655151</id><published>2007-05-11T00:02:00.000-07:00</published><updated>2007-05-14T17:00:07.788-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Roach Motels and The Java Memory Model</title><summary type='text'>I've been asked by a couple of people lately about what a compiler can do with code motion around synchronized blocks.  The first person asked me about the following example, so let's run with it:x = 1;synchronized(o) { z = z + 1;}y = 1;I may have answered this already (at some point), but I feel free to repeat myself.The JMM has what we call "roach motel" ordering.  "Roach Motel" is Black Flag's</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/5549438606677655151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=5549438606677655151' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5549438606677655151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/5549438606677655151'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/05/roach-motels-and-java-memory-model.html' title='Roach Motels and The Java Memory Model'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-773013053740835238</id><published>2007-05-01T18:53:00.000-07:00</published><updated>2007-05-01T18:56:11.376-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><title type='text'>Software Transactional Memory Talk at Google</title><summary type='text'>Adam Welc, from Intel's Programming Systems Lab, came to Google to give a talk about what they are doing in the realm of Software Transactional Memory.  He also talks briefly, at the end, about Intel's hardware plans.For those who are interested in such things, this is a talk worth seeing.Click Here.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/773013053740835238/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=773013053740835238' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/773013053740835238'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/773013053740835238'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/05/software-transactional-memory-talk-at.html' title='Software Transactional Memory Talk at Google'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-8587392594485334167</id><published>2007-04-17T13:41:00.000-07:00</published><updated>2007-04-17T13:59:36.369-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><title type='text'>Lock-Free Hash Tables</title><summary type='text'>I forgot to post about this at the time.  Cliff Click gave a talk about his lock-free hashtable at Google; it is definitely worth a peek.  Available here.There is a very funny thread on the concurrency-interest mailing list this week about "lock-free mania".  Apparently, software engineers are going to start choosing "trendy" lock-free data structures for no valid reason, resulting in lots of </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/8587392594485334167/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=8587392594485334167' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8587392594485334167'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8587392594485334167'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/04/lock-free-hash-tables.html' title='Lock-Free Hash Tables'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-7818453429538505981</id><published>2007-04-10T20:52:00.000-07:00</published><updated>2007-04-10T21:26:50.964-07:00</updated><title type='text'>Fairness</title><summary type='text'>Okay, so I lied about the contents of my next post.  I bet no one even notices.  Anyone even reading these?  Yeah, right.I was asked a question about fairness.  The notion of fairness is one where there are some number of individual entities trying to make progress (in our case, threads), and there is some level of guarantee that this will actually happen.Java has no meaningful fairness guarantee</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/7818453429538505981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=7818453429538505981' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7818453429538505981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/7818453429538505981'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/04/fairness.html' title='Fairness'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-122383394305393866</id><published>2007-03-31T18:55:00.000-07:00</published><updated>2007-03-31T21:45:09.498-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Safe Construction and the JMM</title><summary type='text'>Another question from a viewer.  We have this code:class C {  private int x;  public C(int v) {    this.x = v;  }  public synchronized int get() {    return this.x;  }  public synchronized void set(int v) {    this.x = v;  }}(For the actual question as it was worded, the short answer is, "yes")The question was one I get a lot.  He asked how one thread can safely read the initial write of v to x.</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/122383394305393866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=122383394305393866' title='21 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/122383394305393866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/122383394305393866'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/safe-construction-and-jmm.html' title='Safe Construction and the JMM'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>21</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-9154613931723638449</id><published>2007-03-28T15:41:00.001-07:00</published><updated>2010-05-26T22:35:14.207-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Slides from JMM talk</title><summary type='text'>The slides from the JMM talk are available here for people's perusal.  Enjoy!</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/9154613931723638449/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=9154613931723638449' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/9154613931723638449'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/9154613931723638449'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/slides-from-jmm-talk.html' title='Slides from JMM talk'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-9145242792601369734</id><published>2007-03-27T14:54:00.000-07:00</published><updated>2009-06-17T10:43:26.042-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><category scheme='http://www.blogger.com/atom/ns#' term='Volatile Keyword'/><title type='text'>Volatile Fields and Synchronization</title><summary type='text'>A question from a viewer.  In my talk, I had a class that looked like this:class Future { private volatile boolean ready; private Obj data; ... public synchronized void setOnce(Obj o) {  if (ready) throw ...;  data = o;  ready = true; } public Object get() {  if (!ready)   return null;  return data; }}The setOnce method is executed by one thread, and get is executed by another.  The point of this</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/9145242792601369734/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=9145242792601369734' title='23 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/9145242792601369734'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/9145242792601369734'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/volatile-fields-and-synchronization.html' title='Volatile Fields and Synchronization'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>23</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-8275095647265473261</id><published>2007-03-26T14:15:00.000-07:00</published><updated>2007-03-26T14:22:11.423-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>JMM Talk at Google</title><summary type='text'>This fellow is rather handsome, dashing and well-informed.  If you would like a primer on the Java memory model, this is a good place to start.  I was running out of time toward the end, though, so the last 15 minutes may be a little rushed.  Perhaps I'll do a two-part followup at some point.One thing I forgot to say, at the very beginning: The Java memory model defines how threads interact </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/8275095647265473261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=8275095647265473261' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8275095647265473261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/8275095647265473261'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/jmm-talk-at-google.html' title='JMM Talk at Google'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-1332265666099144209</id><published>2007-03-22T23:54:00.000-07:00</published><updated>2007-03-23T00:36:07.148-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>HashMap Behavior in JDK6</title><summary type='text'>It is important to read the documentation.  Lots of people don't seem to do this, and they get bitten by it.The iterator for java.util.HashSet is documented as follows:Returns an iterator over the elements in this set. The elements are returned in no particular order.Of course, I've now seen code that ignores this, so I thought I would draw a few underlines for the kind of folks who miss it.  I </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/1332265666099144209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=1332265666099144209' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1332265666099144209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1332265666099144209'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/hashmap-behavior-in-jdk6.html' title='HashMap Behavior in JDK6'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-2351268873622685547</id><published>2007-03-21T21:20:00.000-07:00</published><updated>2007-03-23T00:28:41.628-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>Loop Invariant Code Motion and the Java Memory Model</title><summary type='text'>I gave a talk on the Java memory model this afternoon, and there was a question from the audience which I didn't answer to my own satisfaction, so I am answering it again, for my vast readership of none.At issue was the following bit of code:class Animator implements Runnable { private volatile boolean stop = false; public void stop() { stop = true; } public void run() {  while (!stop) {   </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/2351268873622685547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=2351268873622685547' title='14 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2351268873622685547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/2351268873622685547'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/loop-invariant-code-motion-and-java.html' title='Loop Invariant Code Motion and the Java Memory Model'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>14</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-1803766144675136084</id><published>2007-03-21T12:18:00.000-07:00</published><updated>2007-03-21T21:42:09.005-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='Java Memory Model'/><title type='text'>JMM questions go here</title><summary type='text'>I just gave a talk in which I said that people could post questions on the Java memory model here.  So feel free to post JMM questions below!</summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/1803766144675136084/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=1803766144675136084' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1803766144675136084'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/1803766144675136084'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/jmm-questions-go-here.html' title='JMM questions go here'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8405107760807432973.post-3634597482149925050</id><published>2007-03-13T00:34:00.000-07:00</published><updated>2007-03-13T01:05:54.471-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Google Talks'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ Is Getting More Like Java Every Day</title><summary type='text'>Lawrence Crowl gave an interesting talk at Google last week.  It would seem that the next revision of the C++ standard is getting:A new memory model,Garbage collection,Concepts (which are more-or-less type checking for templates.  This roughly boils down to "generics")Unicode support,A regular expression library,A for-each loop!This is all starting to sound terribly familiar.  I'm starting to </summary><link rel='replies' type='application/atom+xml' href='http://jeremymanson.blogspot.com/feeds/3634597482149925050/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8405107760807432973&amp;postID=3634597482149925050' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3634597482149925050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8405107760807432973/posts/default/3634597482149925050'/><link rel='alternate' type='text/html' href='http://jeremymanson.blogspot.com/2007/03/c-is-getting-more-like-java-every-day.html' title='C++ Is Getting More Like Java Every Day'/><author><name>Jeremy Manson</name><uri>http://www.blogger.com/profile/04241094734813086257</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='http://3.bp.blogspot.com/_Kd3ZRwid36g/SPQ45cHj9UI/AAAAAAAAAAM/9BkGwSDrYX4/S220/MyPicture.jpg'/></author><thr:total>0</thr:total></entry></feed>
