On Mar 24, 2014, at 8:30 PM, Mike Duigou <mike.dui...@oracle.com> wrote: > The other issue here, and why this thread has gone on so long, is that we've > been trying to establish what the best idiom is (for 2014-????) for this lazy > initialization situation so that we can reuse it with less thought and > review. In this case the chances of race are fairly low and the cost of extra > layoutChars is bearable. In other cases where we are likely to use the same > idiom this is less likely true. Peter's current implementation has the > advantage that is the best-right answer for lazy initialization even in the > contended/expensive case. I look forward to revisiting this again when the > new JMM primitives are available. :-) >
This is another example of a stable variable. I would like to re-iterate my scepticism that such changes are necessary in this case (i am not sure if it is possible to create a benchmark that could better exacerbate the concurrent overlap of calls to layoutChars). But, i do agree the discussion has been useful and interesting. Paul.