On Mar 10, 2009, at 12:15 AM, is_maximum wrote:
But one more question. Is there any way to join a new created thread
to the
currect transaction in which the thread is created? I ask this
because in
another usecase we have this issue in which when this thread is
starting
there is no transaction associated with it and it complains the
context has
been closed or something like that. Now we use UserTransaction to
get around
the problem but as you know in this case if the main tx being rolled
back
the thread will proceed its way
I'm not aware of any transaction managers that allow a transaction to
spawn multiple threads. There's a one-tread-per-transaction rule in
all the impls I'm aware of, which stems from the use of thread locals
to control the transaction and coordinate with all the resources that
are touched in the scope of that transaction. Going outside the
thread means going outside the sight of the transaction manager.
Even in the new EJB 3.1 Asynchronous method invocation, the methods
invoked asynchronously will be in a different transaction (and thread
of course) from the client that invoked the bean.
-David