[jboss-cvs] JBossCache/tests/stress/org/jboss/cache ...
Elias Ross
genman at noderunner.net
Fri Dec 8 14:00:38 EST 2006
User: genman
Date: 06/12/08 14:00:38
Modified: tests/stress/org/jboss/cache
ReadWriteLockWithUpgradeStressTest.java
Log:
JBCACHE-891 Use JDK 1.5 lock classes
Revision Changes Path
1.2 +16 -14 JBossCache/tests/stress/org/jboss/cache/ReadWriteLockWithUpgradeStressTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ReadWriteLockWithUpgradeStressTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/stress/org/jboss/cache/ReadWriteLockWithUpgradeStressTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ReadWriteLockWithUpgradeStressTest.java 8 Jul 2005 05:58:10 -0000 1.1
+++ ReadWriteLockWithUpgradeStressTest.java 8 Dec 2006 19:00:38 -0000 1.2
@@ -1,6 +1,8 @@
package org.jboss.cache;
-import EDU.oswego.cs.dl.util.concurrent.Sync;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -59,8 +61,8 @@
final int NUM=1000000;
for(int i=0; i < NUM; i++) {
- l.writeLock().attempt(2000);
- l.writeLock().release();
+ l.writeLock().tryLock(2000, TimeUnit.MILLISECONDS);
+ l.writeLock().unlock();
if(i % 10000 == 0)
System.out.println(i);
}
@@ -77,10 +79,10 @@
for (int i = 0; i < LOOPS; i++) {
int duration = rand.nextInt((int) SLEEP_MSECS);
_sleep(SLEEP_MSECS);
- Sync rlock = null;
+ Lock rlock = null;
try {
rlock = lock_.readLock();
- if (!rlock.attempt(msecs)) {
+ if (!rlock.tryLock(msecs, TimeUnit.MILLISECONDS)) {
log("Read lock attempt failed.");
// fail("Read lock attempt failed.");
counter++;
@@ -92,7 +94,7 @@
} catch (Exception ex) {
}
finally {
- rlock.release();
+ rlock.unlock();
}
}
}
@@ -109,10 +111,10 @@
for (int i = 0; i < LOOPS; i++) {
int duration = rand.nextInt((int) SLEEP_MSECS);
_sleep(SLEEP_MSECS + duration);
- Sync wlock = null;
+ Lock wlock = null;
try {
wlock = lock_.writeLock();
- if (!wlock.attempt(msecs)) {
+ if (!wlock.tryLock(msecs, TimeUnit.MILLISECONDS)) {
log("Write lock attempt failed.");
// fail("Write lock attempt failed.");
counter++;
@@ -124,7 +126,7 @@
} catch (Exception ex) {
}
finally {
- wlock.release();
+ wlock.unlock();
}
}
}
@@ -141,11 +143,11 @@
for (int i = 0; i < LOOPS; i++) {
int duration = rand.nextInt((int) SLEEP_MSECS);
_sleep(SLEEP_MSECS);
- Sync rlock = null;
- Sync wlock = null;
+ Lock rlock = null;
+ Lock wlock = null;
try {
rlock = lock_.readLock();
- if (!wlock.attempt(msecs)) {
+ if (!wlock.tryLock(msecs, TimeUnit.MILLISECONDS)) {
log("Read lock attempt failed.");
// fail("Read lock attempt failed.");
counter++;
@@ -159,7 +161,7 @@
if (wlock == null) {
log("upgrade lock attempt failed");
// fail("upgrade lock attempt failed");
- rlock.release();
+ rlock.unlock();
counter++;
}
@@ -170,7 +172,7 @@
}
finally {
if(wlock != null)
- wlock.release();
+ wlock.unlock();
}
}
}
More information about the jboss-cvs-commits
mailing list