commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <>
Subject Re: [lang] FastNumberFormat?
Date Wed, 11 Aug 2004 05:10:22 GMT
On Tue, 10 Aug 2004 20:10:46 -0700, Martin Cooper <> wrote:
> On Tue, 10 Aug 2004 17:27:30 -0400, Gary Gregory
> <> wrote:
> > Why not give each thread its own DecimalFormat instance in a thread
> > local variable? Then you do not have to worry about it.
> That's most likely what I'll end up doing. I was just hoping to get
> rid of synchronisation altogether, including the lock checks.

You might want to review how ThreadLocal variables are implemented,
though ... it's most likely to be some sort of HashMap keyed by
classloader, and the get/put operations to update your thread's local
copy are likely to be synchronized internally.

The best way to avoid synchronization is likely to create one in a
local variable, then pass it around to whomever needs it.  Ugly, but
performance hacks are sometimes like that.

> --
> Martin Cooper


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message