Re: JavaMemoryModel: Code in the JDK that fails under current memory model

From: Joseph Bowbeer (
Date: Sun Jul 18 1999 - 18:00:09 EDT

----- Original Message -----
From: Bill Pugh <>
To: <>
Sent: Monday, July 12, 1999 11:40 AM

> Has anyone put together a list of places
> in the JDK that assume initialization safety?
> Here are some I've found:
> There are synchronized setFoo and matching unsynchronized getFoo
> methods, operating on references, in:
> java/awt/CheckboxGroup.set/get Current

+ java/awt/Checkbox.set/get CheckboxGroup:

    public void setCheckboxGroup(CheckboxGroup g) {
        CheckboxGroup group =;
        if (group != null) {
        /* Locking check box above could cause deadlock with
         * CheckboxGroup's setSelectedCheckbox method.
        synchronized (this) {
   = g;
            /* ... */

Fortunately, none of your examples notify any listeners. To avoid deadlock,
the beans spec advises against holding a lock while listeners are being
notified. (For example, one thread may be trying to remove a listener while
another thread is trying to notify the listener.) This however *is* the case
with java/awt/Component's half-sync'd set/get Font methods. Yikes.

Joe Bowbeer

------------------------------- This is the JavaMemoryModel mailing list, managed by Majordomo 1.94.4.

To send a message to the list, email To send a request to the list, email and put your request in the body of the message (use the request "help" for help). For more information, visit

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