Browse Source

add volatile

JamesZhan 13 years ago
parent
commit
a10db087cc

+ 1 - 1
src/com/jfinal/i18n/I18N.java

@@ -46,7 +46,7 @@ public class I18N {
 	private static final NullResourceBundle NULL_RESOURCE_BUNDLE = new NullResourceBundle();
 	private static final ConcurrentMap<String, ResourceBundle> bundlesMap = new ConcurrentHashMap<String, ResourceBundle>();
 	
-	private static I18N me;
+	private static volatile I18N me;
 	
 	private I18N() {
 	}

+ 1 - 1
src/com/jfinal/plugin/ehcache/CacheKit.java

@@ -27,7 +27,7 @@ import net.sf.ehcache.Element;
  */
 public class CacheKit {
 	
-	private static CacheManager cacheManager;
+	private static volatile CacheManager cacheManager;
 	private static final Logger log = Logger.getLogger(CacheKit.class);
 	
 	static void init(CacheManager cacheManager) {

+ 3 - 3
src/com/jfinal/util/SessionIdGenerator.java

@@ -28,7 +28,7 @@ public class SessionIdGenerator {
 	
     protected static Random random;
     private static boolean weakRandom;
-    private static final Object lock = new Object();
+    private static volatile Object lock = new Object();
     
     private static final SessionIdGenerator me = new SessionIdGenerator();
     
@@ -54,8 +54,8 @@ public class SessionIdGenerator {
     
 	public String generate(HttpServletRequest request, HttpServletResponse response) {
         synchronized (lock) {
-            String id=null;
-            while (id==null || id.length()==0) {	//)||idInUse(id))
+            String id = null;
+            while (id == null || id.length() == 0) {	//)||idInUse(id))
                 long r0 = weakRandom ? (hashCode()^Runtime.getRuntime().freeMemory()^random.nextInt()^(((long)request.hashCode())<<32)) : random.nextLong();
                 long r1 = random.nextLong();
                 if (r0<0) r0 = -r0;