英文:
Do implementations of interface javax.transaction.Transaction need to be thread safe?
问题
以下是您要翻译的内容:
javax.transaction.Transaction
的符合实现是否需要支持多线程安全?
预期这些实现是否需要处理来自不同线程的并发请求?
以一个示例说明:
// 线程A
transaction.commit();
// 在提交仍在运行时的线程B
transaction.setRollbackOnly();
我提出这个问题是因为我可以看到Infinispan以这种方式与事务管理器交互,从而导致死锁。我想了解这是Infinispan中的bug还是事务管理器中的问题。
英文:
Do conforming implementations of javax.transaction.Transaction
need to be thread safe?
Are implementations of this expected to handle concurrent requests from different threads?
As an example:
// Thread A
transaction.commit();
// Thread B, while that commit is still running
transaction.setRollbackOnly();
I am asking this question because I can see Infinispan interacting with the transaction manager in this way which results in a deadlock. I want to understand if this is a bug in Infinispan or the transaction manager.
答案1
得分: 2
JTA 表示:
§3.3 - 事务接口
>Transaction.commit
和 Transaction.rollback
方法允许提交或回滚目标对象的事务。调用线程不必要求与线程关联相同的事务。如果不允许调用线程提交事务,则事务管理器会抛出异常。
规范未对此点做出更多说明;因此,厂商不需要必须提供对 javax.transaction.Transaction
的线程安全实现。
英文:
JTA says, that:
§3.3 - Transaction Interface
>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.
Specification does not say anything more about this point; therefore, it is not required, pre se, that the vendor must provide a thread-safe implementation of javax.transaction.Transaction
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论