As I read in Beggining With 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.
So... what's the difference? Both annotation disables concurrent invocations and I don't see any difference beetwen them. Is there any situation when it makes sense to use them together?
The first method will block subsequent callers until the current one finish its call. The second, @AccessTimeoutvalue
will throw an exception if there are more than one calls at the same time. Quite a difference.