"applicationContext.xml");
// Get bean
final Reader reader = (Reader) ctx.getBean("readerThread");
final Updater updater = (Updater) ctx.getBean("updaterThread");
final UpdaterNoWait updaterNoWait = (UpdaterNoWait) ctx
.getBean("updaterNoWaitThread");
// Get thread
Thread thReader = new Thread() {
@SuppressWarnings("boxing")
@Override
public void run() {
try {
reader.action();
} catch (DataAccessException dae) {
// Check if there is a lock exception...
if (dae instanceof TopLinkOptimisticLockingFailureException) {
System.out
.printf(
"THREAD ID : %s --> Version diff�rente !!!\n",
Thread.currentThread().getId());
} else {
System.out
.printf(
"THREAD ID : %s --> Exception : %s !!!\n",
Thread.currentThread().getId(), dae
.getMessage());
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
Thread thUpdater = new Thread() {
@SuppressWarnings("boxing")
@Override
public void run() {
try {
updater.action();
System.out.printf(
"THREAD ID : %s --> Data updated !!!\n",
Thread.currentThread().getId());
} catch (DataAccessException dae) {
// Check if there is a lock exception...
if (dae instanceof TopLinkOptimisticLockingFailureException) {
System.out
.printf(
"THREAD ID : %s --> Version diff�rente !!!\n",
Thread.currentThread().getId());
} else {
System.out
.printf(
"THREAD ID : %s --> Exception : %s !!!\n",
Thread.currentThread().getId(), dae
.getMessage());
}
} catch (InterruptedException ie) {
ie.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
};
Thread thUpdaterNoWait = new Thread() {
@SuppressWarnings("boxing")
@Override
public void run() {
try {
updaterNoWait.action();
System.out.printf(
"THREAD ID : %s --> Data updated !!!\n",
Thread.currentThread().getId());
} catch (DataAccessException dae) {
// Check if there is a lock exception...