Skip to content

Commit

Permalink
double check lock (#6422)
Browse files Browse the repository at this point in the history
  • Loading branch information
diguage authored Jul 7, 2020
1 parent 9d5e8b3 commit feb679b
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public class DubboBootstrap extends GenericEventListener {

private final Logger logger = LoggerFactory.getLogger(getClass());

private static DubboBootstrap instance;
private static volatile DubboBootstrap instance;

private final AtomicBoolean awaited = new AtomicBoolean(false);

Expand Down Expand Up @@ -176,9 +176,13 @@ public class DubboBootstrap extends GenericEventListener {
/**
* See {@link ApplicationModel} and {@link ExtensionLoader} for why DubboBootstrap is designed to be singleton.
*/
public static synchronized DubboBootstrap getInstance() {
public static DubboBootstrap getInstance() {
if (instance == null) {
instance = new DubboBootstrap();
synchronized (DubboBootstrap.class) {
if (instance == null) {
instance = new DubboBootstrap();
}
}
}
return instance;
}
Expand Down

0 comments on commit feb679b

Please sign in to comment.