Hi there at JBoss Forums,
I am possibly missing something very obvious, but after reading loads of material I still cannot figure it out - so I'd thought I'd ask the experts.
I have the following method in a stateless session bean (the entity manager is injected)
public void test(String id, String value, long sleep) {
SimpleTestEntityBean bean = em.find(SimpleTestEntityBean.class, id);
try {
Thread.sleep(sleep);
} catch (InterruptedException exception) {
exception.printStackTrace();
}
System.out.println(id + " setting state to " + value);
bean.setValue(value);
}
Thread firstRunner = new Thread() {
public void run() {
SimpleTestFacadeAccess.getInstance().test("1", "BOGUS", 5000);
}
};
Thread secondRunner = new Thread() {
public void run() {
SimpleTestFacadeAccess.getInstance().test("1", "OTHER_BOGUS", 2000);
}
};
System.out.println ("Starting A simple");
firstRunner.start();
try {
Thread.sleep(750);
} catch (InterruptedException exception) {
exception.printStackTrace();
}
System.out.println ("Starting B simple");
secondRunner.start();