Author: manik.surtani(a)jboss.com
Date: 2009-03-11 06:04:36 -0400 (Wed, 11 Mar 2009)
New Revision: 7898
Modified:
core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransaction.java
Log:
Reduced synchronization
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransaction.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransaction.java 2009-03-11
10:00:29 UTC (rev 7897)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/GlobalTransaction.java 2009-03-11
10:04:36 UTC (rev 7898)
@@ -28,6 +28,7 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.util.concurrent.atomic.AtomicLong;
/**
@@ -44,7 +45,7 @@
private static final long serialVersionUID = 8011434781266976149L;
- private static long sid = 0;
+ private static AtomicLong sid = new AtomicLong(0);
private Address addr = null;
private long id = -1;
@@ -63,14 +64,9 @@
private GlobalTransaction(Address addr)
{
this.addr = addr;
- id = newId();
+ id = sid.getAndIncrement();
}
- private static synchronized long newId()
- {
- return ++sid;
- }
-
public static GlobalTransaction create(Address addr)
{
return new GlobalTransaction(addr);
Show replies by date