}
}
}
public void sequence() {
final HostDao hostDao = new HostDaoImpl();
long seq = hostDao.getNextSequence(1);
s_logger.info("******* seq : " + seq + " ********");
HashMap<Long, Long> hashMap = new HashMap<Long, Long>();
final Map<Long, Long> map = Collections.synchronizedMap(hashMap);
s_count = 0;
final long maxCount = 1000000; // test one million times
Thread t1 = new Thread(new Runnable() {
public void run() {
while(s_count < maxCount) {
s_count++;
long seq = hostDao.getNextSequence(1);
Assert.assertTrue(map.put(seq, seq) == null);
}
}
});
Thread t2 = new Thread(new Runnable() {
public void run() {
while(s_count < maxCount) {
s_count++;
long seq = hostDao.getNextSequence(1);
Assert.assertTrue(map.put(seq, seq) == null);
}
}
});