I don't see a functional issue with this;
The DateTimeFormatter created by each thread will have exactly the same 
behavior and semantics.
The caller gets an instance that preforms as required.

dt is just a cache to improve performance.

The only condition at risk is the two calls to dateTime() do not return 
the same (==) instance.

 From the callers point of view what other observable behavior might be 
different?

Roger



On 7/12/2013 5:27 AM, Stephen Colebourne wrote:
> You may be right, although neither volatile nor synchronized are appealing 
> here.
> Please raise an issue on GitHub
> Stephen
>
> On 12 July 2013 10:19, Lin Wang <superno...@gmail.com> wrote:
>> The javadoc of ISODateTimeFormat class says it's thread-safe and immutable.
>> The static fields are lazily initialized. However it seems it's not done in
>> a thread-safe manner.
>>
>> For example, dt is lazily initialized in
>>      public static DateTimeFormatter dateTime() {
>>          if (dt == null) {
>>              dt = new DateTimeFormatterBuilder()
>>                  .append(date())
>>                  .append(tTime())
>>                  .toFormatter();
>>          }
>>          return dt;
>>      }
>>
>> When there are two threads both inside this method, is it possible that one
>> thread sees an unsafely published non-null dt value due to cache
>> incoherence?
>>
>> Did I miss something?
>>
>> ------------------------------------------------------------------------------
>> See everything from the browser to the database with AppDynamics
>> Get end-to-end visibility with application monitoring from AppDynamics
>> Isolate bottlenecks and diagnose root cause in seconds.
>> Start your free trial of AppDynamics Pro today!
>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Joda-interest mailing list
>> Joda-interest@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/joda-interest
>>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Joda-interest mailing list
> Joda-interest@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/joda-interest


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to