Firstly, HF EJB says that we are not supposed to write any thread related code such as synchronized, wait, notify, Thread class...To be frank with you I laughed in my mind "Ohoh! So, I can escape from thread codes in EJB, hurrah!!!".....But then ur code made me sit up and see whatz that thread code inside SB.
Secondly, SB does not know whether business methods call from client through the body guard(EJBObject) is coming from one or two windows. Both methods are from same client AFTER ALL!!!
It is as good as calling "add an item" to cart first and the calling "remove the item" from cart from a single window.
And I dont know how container will handle, if in case these method calls are going simultaneously from two windows from a single client. I want to avoid thread codes as HF says, haa....
Stateful bean can leave a tx open in a method. If a client calls a method from stateful bean which opens a tx and then calls a method which does not use same tx, error will be thrown. Bcos, opened tx is not yet commited/rolled back. But client is trying to use some other tx. This is my humble opinion.
If SB instance is participating in a Txn , its an err for a client to invoke a method on SB instance such that the txn attrribute in DD wud cause
container to execute the method in difrent txn ctx or in unspecified txn ctx....