RE: JavaMemoryModel: Another Java threading issue (finalization)

From: Igor Pechtchanski (igor@watson.ibm.com)
Date: Tue Apr 01 2003 - 18:42:41 EST


On Tue, 1 Apr 2003, Paul Jakubik wrote:

> My understanding of what has been proposed in this thread is
> that the developer should do the following:
>
> If your class has a finalizer you must synchronize any
> potential last-method-call and the finalizer.
>
> If I understand this correctly, this sounds like bad news for
> library developers. It would mean that every method and the
> finalizer should be synchronized (at least every public
> method). The library would be made significantly slower in
> hopes of allowing an optimization to make the library a little
> faster.
>
> Am I missing something? If my interpretation is right, are
> there alternatives that would make the developer's life easier?
> --Paul

I'm sorry to be jumping in here, but as far as I understand, if you want
your library to be thread-safe, you'll need to synchronize all public (and
protected) methods in it anyway, so you're not really losing any
performance. Besides, (a) it's safer to eliminate unnecessary
synchronization in the compiler, and (b) locks are cheap anyway unless
there's contention...
        Igor

-- 
Igor Pechtchanski               "I love deadlines.  I love the whooshing noise
IBM T.J.Watson Research Center  they make as they go past."
igor@watson.ibm.com                -- Douglas Adams
(914)784-6162

------------------------------- JavaMemoryModel mailing list - http://www.cs.umd.edu/~pugh/java/memoryModel



This archive was generated by hypermail 2b29 : Thu Oct 13 2005 - 07:00:43 EDT