[jboss-cvs] JBossCache/tests/perf/org/jboss/cache/manualtests ...
Manik Surtani
msurtani at jboss.com
Fri Feb 2 11:34:23 EST 2007
User: msurtani
Date: 07/02/02 11:34:23
Added: tests/perf/org/jboss/cache/manualtests
HashMapConcurrencyTest.java
Log:
experiment
Revision Changes Path
1.1 date: 2007/02/02 16:34:23; author: msurtani; state: Exp;JBossCache/tests/perf/org/jboss/cache/manualtests/HashMapConcurrencyTest.java
Index: HashMapConcurrencyTest.java
===================================================================
package org.jboss.cache.manualtests;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
public class HashMapConcurrencyTest
{
private static final int T = 100;
private static final int N = 1000;
private static final Random R = new Random();
private static final CountDownLatch latch = new CountDownLatch(1);
private static final Map map = new HashMap();
public static void main(String[] args)
{
Thread[] threads = new Thread[T];
for (int i = 0; i < T; i++)
{
threads[i] = new Thread()
{
public void run()
{
try
{
latch.await();
for (int j = 0; j < N; j++)
{
if (R.nextInt() % 2 == 0)
{
map.get("key");
}
else
{
map.put("key", "value");
}
}
}
catch (Exception e)
{
}
}
};
threads[i].start();
}
latch.countDown();
for (int i = 0; i < T; i++)
{
try
{
threads[i].join();
}
catch (InterruptedException e)
{
}
}
}
}
More information about the jboss-cvs-commits
mailing list