[concurrency-interest] Synchronizing on AtomicBoolean safe?

Nikolai V. Chr. nikolai at ifad.dk
Wed Jun 29 10:38:26 EDT 2005


Is this sane? If not, how could I do it? I used to use getLock() on 
Lea's old SynchronizedBoolean.

AtomicBoolean protocolSupportEnabled = new AtomicBoolean(false);

synchronized(protocolSupportEnabled) {
   old = protocolSupportEnabled.getAndSet(enable);
   if(enable) {
      
propertyChangeMulticaster.addPropertyChangeListenerIfAbsent(protocolListener);
   } else {
      
propertyChangeMulticaster.removePropertyChangeListener(protocolListener);
   }
   logProtocolSupportEnabled(enable);
}

-- 
Nikolai V. Christensen, Computer Engineer,
Simulation and Training department
IFAD TS A/S, Østre stationsvej 43 2.tv, DK-5000 Odense C
Denmark, EU
Phone: +45 63 11 02 11  Fax: +45 65 93 29 99
WWWeb: http://www.ifad.dk
e-mail: Nikolai.V.Christensen at ifad.dk
--




More information about the Concurrency-interest mailing list