标签:
public class MyObject { private volatile static MyObject myObject; private MyObject(){} public static MyObject getInstance(){ try { if(myObject != null){ }else{ Thread.sleep(3000); synchronized ( MyObject.class) { if(myObject == null){ myObject = new MyObject(); } } } } catch (Exception e) { e.printStackTrace(); } return myObject; } }
标签:
原文地址:http://www.cnblogs.com/acode/p/5825981.html