When using locks, you must consider what happens if something fails within the operation inside a lock. Java locks do not apply ACID (atomic, consistent, isolated, durable) rules as databases do. Using explicit or intrinsic locks, you can perform compound actions in isolation. Changes are also durable (if the field declarations allow that). At the same time, locks do not make any guarantees with regards to consistency (valid object state) or atomicity (perform all-or-nothing).
If an exception is thrown inside a compound action that is guarded by a lock, then everything that happened before the exception will be durable. But the rest of that operation wasn't executed, probably leaving the state of the processed objects in an inconsistent state.
from DZone.com Feed https://ift.tt/2I1JPjs
No comments:
Post a Comment