Look at the confusion caused by the release object in the actual combat of concurrent programming.

when you see unsafe object publishing in Concurrency Practice, there is a publication that publishes an internal class instance. The code is as follows:

public class ThisEscape{
    public ThisEscape(EventSource source){
        source.registerListener(
            new EventListener(){
                public void onEvent(Event e){
                    doSomething(e);
                }
            }
        )
    }
}

Why are the objects implicitly published here?

Mar.05,2021

doSomething (e); is an instance method of the outer object and publishes the ThisEscape.this reference

Menu