import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestMultiThreadAddDelete {
+ private static final Logger LOG = LoggerFactory.getLogger(TestMultiThreadAddDelete.class);
private static final int RETRIES = 1;
private static final int N_THREADS = 7;
private static final int COUNT = 50 * 1000;
if (j % N_THREADS == threadNo) {
bt.put(Integer.valueOf(j), Integer.valueOf(j));
if (!bt.containsKey(Integer.valueOf(j))) {
- System.out.println(j);
+ LOG.error("Key {} not present", j);
}
bt.remove(Integer.valueOf(j));
if (bt.containsKey(Integer.valueOf(j))) {
- System.out.println(-j);
+ LOG.error("Key {} is still present", j);
}
}
}
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestMultiThreadMapIterator {
+ private static final Logger LOG = LoggerFactory.getLogger(TestMultiThreadMapIterator.class);
private static final int NTHREADS = 7;
@Test
}
}
- // System.out.println("Size of initialized map is " + bt.size());
+ LOG.debug("Size of initialized map is {}", bt.size());
int count = 0;
{
final ExecutorService es = Executors.newFixedThreadPool(NTHREADS);
Object key = e.getKey();
if (accepts(threadNo, NTHREADS, key)) {
if (null == bt.get(key)) {
- // System.out.println(key);
+ LOG.error("Key {} is not present", key);
}
it.remove();
if (null != bt.get(key)) {
- // System.out.println(key);
+ LOG.error("Key {} is still present", key);
}
removed.put(key, key);
}
}
for (final Object o : bt.keySet()) {
if (!removed.contains(bt.get(o))) {
- System.out.println("Not removed: " + o);
+ LOG.error("Not removed: {}", o);
}
}
assertEquals(0, count);