[concurrency-interest] dealing with peoplethatquestionvisibility problems

Peter Veentjer alarmnummer at gmail.com
Thu Mar 1 09:19:18 EST 2007


Hi Matthias,

>>as I understand "action2" comes before "action1". Construction also
happens >> under the lock of the application context.

It is corrected. It appears I did non drink enough coffee. Thank you.

>> And I don't understand why you say this is only safe
>> since 1.5. If the following is not safe in 1.4 what is?

If the dao is not final (and final even doesn't work correctly under
older virtual machines because of reordenings that are forbidden under
Java 5 and higher), or volatile, or used in a synchronized context,
then I don't know a way to safely publish that variable under 1.4.

I probably will work because most cpu's have a very strong cache coherence.

On 3/1/07, Ernst, Matthias <matthias.ernst at coremedia.com> wrote:
>
>
>
> > I have made a few small changes to the blogentry
>
>  Peter,
>
>  two remarks:
>
>  as I understand "action2" comes before "action1". Construction also happens
> under the lock of the application context.
>  And I don't understand why you say this is only safe since 1.5. If the
> following is not safe in 1.4 what is?
>
>  T1:
>  synchronized(map) {
>    manager = map.get("manager");
>    if(manager == null) {
>      manager = new Manager();
>      manager.setDao(dao);
>      map.put("manager", manager);
>    }
>  }
>
>  T2:
>  synchronized(map) {
>    manager = map.get("manager");
>    // not null
>  }
>  manager.fire(...);
>
>
>
>  Matthias
>
>
>


More information about the Concurrency-interest mailing list