svn commit: r948444 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r948444 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java

doogie-3
Author: doogie
Date: Wed May 26 14:22:46 2010
New Revision: 948444

URL: http://svn.apache.org/viewvc?rev=948444&view=rev
Log:
Remove synchronized on staticTimers access(non-blocking).

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java?rev=948444&r1=948443&r2=948444&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilTimer.java Wed May 26 14:22:46 2010
@@ -18,8 +18,6 @@
  *******************************************************************************/
 package org.ofbiz.base.util;
 
-import java.util.Map;
-
 import javolution.util.FastMap;
 
 /**
@@ -32,7 +30,10 @@ import javolution.util.FastMap;
 public class UtilTimer {
 
     public static final String module = UtilTimer.class.getName();
-    protected static Map<String, UtilTimer> staticTimers = FastMap.newInstance();
+    protected static FastMap<String, UtilTimer> staticTimers = FastMap.newInstance();
+    static {
+        staticTimers.setShared(true);
+    }
 
     protected String timerName = null;
     protected String lastMessage = null;
@@ -222,14 +223,10 @@ public class UtilTimer {
     public static UtilTimer getTimer(String timerName, boolean log) {
         UtilTimer timer = staticTimers.get(timerName);
         if (timer == null) {
-            synchronized(UtilTimer.class) {
-                timer = staticTimers.get(timerName);
-                if (timer == null) {
-                    timer = new UtilTimer(timerName, false);
-                    timer.setLog(log);
-                    staticTimers.put(timerName, timer);
-                }
-            }
+            timer = new UtilTimer(timerName, false);
+            timer.setLog(log);
+            staticTimers.putIfAbsent(timerName, timer);
+            timer = staticTimers.get(timerName);
         }
         return timer;
     }
@@ -260,8 +257,6 @@ public class UtilTimer {
         if (message != null) {
             UtilTimer.timerLog(timerName, message, module);
         }
-        synchronized(UtilTimer.class) {
-            staticTimers.remove(timerName);
-        }
+        staticTimers.remove(timerName);
     }
 }