[jboss-dev-forums] [EJB Development] - Re: Entity bean deadlock
le_garcon_enerve
do-not-reply at jboss.com
Fri Sep 25 13:23:41 EDT 2009
Maybe you could use
A: getTitle() {
return name + getSync().getName(getB());
}
B: getTitle() {
return name + getSync().getName(getA());
}
Where Sync is a Singleton with
Sync:
syncronised getName(Bean b){
return b.getName();
}
This way the threads run without interference until on of them calls the getName() of Sync. At this point, one of them is prone to win the race, and the syncronisation within Sync avoids the deadlock.
The penalty for the indirect call to Sync should not be too bad if the three beans are in the same VM.
Didn't try it, though ;-)
Cheers ,
Georg
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4257123#4257123
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4257123
More information about the jboss-dev-forums
mailing list