[concurrency-interest] Pointless synchronized ?

Szabolcs Ferenczi szabolcs.ferenczi at gmail.com
Thu Apr 19 17:31:45 EDT 2007


Isn't it so thread safe as a piece of dead code can be?
Szabolcs

On 19/04/07, Hanson Char <hanson.char at gmail.com> wrote:
> I see code (in some pretty common opensource projects) like:
>
>     private static ThreadLocal registry = new ThreadLocal() {
>         protected synchronized Object initialValue() {
>             // ...
>         }
>     };
>
> It seems pointless to have the initialValue method synchronized, since
> it's thread safe by nature.
>
> Or am I missing something ?
>
> Hanson Char
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at altair.cs.oswego.edu
> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>


More information about the Concurrency-interest mailing list