接口 javax.transaction.Transaction 的实现是否需要线程安全?

Do implementations of interface javax.transaction.Transaction need to be thread safe?

javax.transaction.Transaction 的一致性实现是否需要线程安全?

此实现是否有望处理来自不同线程的并发请求?

举个例子:

// Thread A
transaction.commit();

// Thread B, while that commit is still running
transaction.setRollbackOnly();

我问这个问题是因为我可以看到 Infinispan 以这种方式与事务管理器交互,从而导致死锁。我想了解这是否是 Infinispan 或事务管理器中的错误。

JTA 说:

§3.3 - 交易界面

The Transaction.commit and Transaction.rollback methods allow the target object to be comitted or rolled back. The calling thread is not required to have the same transaction associated with the thread. If the calling thread is not allowed to commit the transaction, the transaction manager throws an exception.

关于这一点规范并没有多说什么;因此,pre se 不需要供应商必须提供 thread-safe javax.transaction.Transaction 的实现。 =15=]