Thread[] ts = new Thread[nbThread];
for (int thread = 0; thread < nbThread; thread++) {
ts[thread] = new Thread(new Runnable() {
public void run() {
TraceTime traceTime = new TraceTime();
String action = null;
Iterator iter = null;
for (int j = 0, i = 0; i < _nbTx; i++) {
traceTime.startTask(Thread.currentThread().getName() + ".loop." + i);
logger.log(BasicLevel.INFO, "Start loop " + i);
Collections.shuffle(_methodsList);
iter = _methodsList.iterator();
boolean deadLock = false;
String returnStr;
while (iter.hasNext()) {
if (0 == (j++ % 100.0)) {
logger.log(BasicLevel.INFO, j + " actions called...");
}
action = (String) iter.next();
// check if the action need to start a transaction
logger.log(BasicLevel.DEBUG, "Calls method:" + action);
deadLock = true;
while (deadLock) {
deadLock = false;
try {
returnStr = performMethod(action);
logger.log(BasicLevel.DEBUG,
"The method " + action + " returns:\n"
+ returnStr);
} catch (JDOFatalException e) {
logger.log( BasicLevel.INFO, "The method "
+ action
+ " throws a JDO Fatal Exception");
deadLock = true;
} catch (Exception e) {
logger.log(BasicLevel.ERROR,
"The method " + action
+ " throws an exception ", e);
fail("The method " + action
+ " throws JDO an exception "
+ e.getMessage());
}
}
}
}
traceTime.endTask();
logger.log(BasicLevel.INFO, "End of thread loops : " + traceTime.report());
}
});
}
//-------------- Launch all threads ------------//