I got this as a private reply, but I believe that it is of general
interest.

- Sam Ruby


Brian Goetz <[EMAIL PROTECTED]> on 01/27/2001 07:40:54 AM

To:   Sam Ruby/Raleigh/IBM@IBMUS
cc:
Subject:  Re: Thread-safety



> Hmm.  Obviously this subject is much more subtle that I expected.  Thanks
> for the clarification, and in particular, the patient way in which you
> presented it.

Sam, I think the suggestions you present are moving in the right
direction.  Synchronization is expensive, so if you can avoid it on
the critical path, that's a throughput win.  One way to do that is as
you suggest, move your initializations into static initializers if you
can.  This works in a lot of cases.  Creating the objects before the
thread also works.  In most cases, there's a way to avoid the
problematic lazy initialization without too much fuss.

I'm not really following the thread too carefully, but Jon asked me to
comment since he knows that this is an area where I had something to
contribute.  Feel free to copy me on your messages or ask questions.

I'll send you a reference to my JavaWorld article on the subject when
it has gone through editorial review.

> I presume that synchronization is a relatively expensive operation,

Unfortunately so.  Newer JVMs are better, but still its a big overhead.

> Anybody have any hard data on the validity of the presumptions above?

I think there's some hard data on this in Dov Bulka's performance
book.  Probably done with Java 1.2; 1.3 might be better.  You can
recompile his tests on your system and gather your own data.

Its late, so that's all for now.




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

Reply via email to