final CountDownLatch startLatch = new CountDownLatch(1);
final CountDownLatch endLatch = new CountDownLatch(threadCount);
final CountDownLatch dumpLatch = new CountDownLatch(1);
Thread[] threads = new Thread[threadCount];
final TableOperator operator = new TableOperator();
operator.setDataSource(dataSource);
operator.createTable();
for (int i = 0; i < threadCount; ++i) {
Thread thread = new Thread() {
public void run() {
try {
startLatch.await();
for (int i = 0; i < LOOP_COUNT; ++i) {
operator.insert();
}
} catch (Exception ex) {
ex.printStackTrace();
}
endLatch.countDown();
try {
dumpLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
threads[i] = thread;
thread.start();
}
long startMillis = System.currentTimeMillis();
long startYGC = TestUtil.getYoungGC();
long startFullGC = TestUtil.getFullGC();
startLatch.countDown();
endLatch.await();
long[] threadIdArray = new long[threads.length];
for (int i = 0; i < threads.length; ++i) {
threadIdArray[i] = threads[i].getId();
}
ThreadInfo[] threadInfoArray = ManagementFactory.getThreadMXBean().getThreadInfo(threadIdArray);
dumpLatch.countDown();
operator.dropTable();
long blockedCount = 0;
long waitedCount = 0;
for (int i = 0; i < threadInfoArray.length; ++i) {
ThreadInfo threadInfo = threadInfoArray[i];