阅读背景:

Java静态初始化器线程安全吗?

来源:互联网 

I'm using a static code block to initialize some controllers in a registry I have. My question is therefore, can I guarantee that this static code block will only absolutely be called once when the class is first loaded? I understand I cannot guarantee when this code block will be called, I'm guessing its when the Classloader first loads it. I realize I could synchronize on the class in the static code block, but my guess is this is actually what happens anyway? I'm using a static code block to initialize som




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: