達內(nèi)在線Java高手加新課1968期
// 雙鎖檢測,在工作中上述兩種情況就能夠滿足了
? ?public static World getInstance() {
? ? ? ?if (SINGLETON_WORLD == null) {
? ? ? ? ? ?synchronized (World.class) {
? ? ? ? ? ? ? ?if (SINGLETON_WORLD == null) {
? ? ? ? ? ? ? ? ? ?SINGLETON_WORLD = new World();
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ?}
? ? ? ?return SINGLETON_WORLD;
? ?}
? ?private World() {
? ?}
標簽: