This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: remove all traces of java.io.FileDescriptor from java.net


Jeff Sturm wrote:

>On Wed, 27 Mar 2002, Bryce McKinlay wrote:
>
>>>Here's my updated patch.  Hans convinced me that close/finalize ought to
>>>synchronize access to fnum, I've included that below.
>>>
>>Hmm, why is that? Also I noticed that it is actually synchronizing 
>>twice, both in finalize and close?
>>
>
>Finalize and close both access fnum, and will run in different threads.  A
>I understand the Java memory model, it is theoretically possible (however
>unlikely) to have the same fd close twice if we don't synchronize.
>
>We'd get the same effect by declaring fnum volatile, if volatile were
>handled correctly.
>

OK, that makes sense, but doesn't only finalize() need to be 
synchronized to get the "volatile barrier" behaviour? Or, at least, only 
close(). I don't see why we need to synchronize twice!

regards

Bryce.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]