解读并发多线程中dcl(double check lock)的时候被操作共享变量需要使用volatile进行修饰
下边拿dcl单例模式进行举例说明:publicclassSingleton{privateintnum=100;privatestaticSingletonsingleton;privateSingleton(){}publicstaticSingletongetSingleton(){if(singleton==null){synchronized(Singleton.class){if(sin