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

huangapple go评论85阅读模式
英文:

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.commitTransaction.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.

huangapple
  • 本文由 发表于 2020年9月3日 13:14:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/63717255.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定