Netty source code InternalLoggerFactory a little confused?

there is a volatile attribute in the netty internal logging framework InternalLoggerFactory that defaultFactory, does not understand why the volatile keyword is added, and if it is to implement a singleton, why not add the getDefaultFactory method in this class

Synchronize lock statement, or double check? If there is no concurrency problem with getDefaultFactory, what is the purpose of volatile here?

Sep.22,2021

volatile is for the reason that threads are visible and unlocked. It is understood that InternalLoggerFactory is a stateless class, that is to say, multithreading to call newDefaultFactory, will not have state disorder, and will eventually achieve the desired results

.
Menu