On Tue, 10 Aug 2004 22:10:22 -0700, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> On Tue, 10 Aug 2004 20:10:46 -0700, Martin Cooper <[EMAIL PROTECTED]> wrote:
> > On Tue, 10 Aug 2004 17:27:30 -0400, Gary Gregory
> > <[EMAIL PROTECTED]> 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.

Interesting point. I've looked at the code, and this doesn't appear to
be the case, at least for Sun JDK 1.4.2.

> 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.

I found a better way - not using DecimalFormat at all. ;-) I looked
more closely at the usage that's causing the problem, and it turns out
that we can just write our own vastly simplified version.

--
Martin Cooper


> > --
> > Martin Cooper
> 
> Craig
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to