[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug #2945] Incorrect synchronization in java.util.logging.ErrorManager

From: nobody
Subject: [Bug #2945] Incorrect synchronization in java.util.logging.ErrorManager
Date: Wed, 26 Mar 2003 11:28:10 -0500

=================== BUG #2945: FULL BUG SNAPSHOT ===================

Submitted by: davidholmes             Project: classpath                    
Submitted on: Thu 03/27/03 at 02:28
Severity:  5 - Major                  Resolution:  None                     
Assigned to:  None                    Status:  Open                         
Platform Version:  None               

Summary:  Incorrect synchronization in java.util.logging.ErrorManager

Original Submission:  ErrorManager.error is a method that should only be 
executed once. To achieve this a field is set so that subsequent invocations 
return immediately. Synchronization is needed to ensure that only one thread 
successfully makes the single call that sets the field.

To avoid synchronization on every call to error() a form of double-checked 
locking is used. However, the double-checked locking idiom does not work unless 
combined with the use of volatile variables (and even then that depends on the 
usage until the new Java Memory Model is finalised and adopted).

In this case the everUsed field must be marked as volatile so that all threads 
are guaranteed to see the value set in it by the thread that successfully 
acquires the lock.

A second issue is that the lock used is that of the ErrorManager class object. 
This forces threads using different ErrorManager objects to serialize through 
the same lock. This is unnecessary. The lock used can simply be that of 'this', 
or a private Object used solely for locking purposes.

No Followups Have Been Posted

CC list is empty

No files currently attached

For detailed info, follow this link:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]