Re: JavaMemoryModel: Finalization idioms

From: Bob Lee (crazyboblee@gmail.com)
Date: Sat Apr 30 2005 - 20:46:05 EDT


My point is that the empty synchronization blocks won't prevent the
finalizer from running before the other methods have completed, nor
will the volatile field accesses in #2. Am I missing something?

Bob

On 4/30/05, Jeremy Manson <jmanson@cs.umd.edu> wrote:
> Empty synchronization blocks can have an effect as long as the object
> being synchronized on is shared across multiple threads. As they would
> be in this case.
>
> You may be thinking of thread-local synchronization. If you do:
>
> synchronized(new Object()) {}
>
> That won't have any effect, because the object isn't shared across
> multiple threads.
>
> Jeremy

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



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