@AccessTimeout(value = 0) 和@Lock(LockType.WRITE) 的区别

Differences between @AccessTimeout(value = 0) and @Lock(LockType.WRITE)

正如我在 中读到的 Java 7 EE:

@Lock(LockType.WRITE): A method associated with an exclusive lock will not allow concurrent invocations until the method’s processing is completed.

An @AccessTimeoutvalue of 0 indicates that concurrent access is not allowed. This will result in throwing a ConcurrentAccessExceptionif a client invokes a method that is currently being used.

所以...有什么区别?这两个注解都禁用并发调用,我看不出它们之间有什么区别。有什么情况可以一起使用它们吗?

第一种方法将阻塞后续调用者,直到当前调用者完成调用。第二,如果同时有多个调用,@AccessTimeoutvalue 将抛出异常。差别很大。