Why is optimistic locking so named?

Why, for example, in java optimistic lock is called this way, and not otherwise?

Author: Kyubey, 2016-03-28

1 answers

In the case of using optimistic locking (optimistic lock), you first try to perform actions, and only then see if the result leads to data inconsistency (conflict of changes, etc.). The name itself comes from the fact that with an optimistic lock, the probability of a conflict is assumed to be small and you perform actions that are called " for good luck" (in the hope that there will be no conflict).

In in contrast, when using pessimistic locking (pessimistic lock), you completely block the resource, and then perform actions on it. In this case, you very much doubt that your actions will end without a conflict.

 14
Author: Dmitriy Simushev, 2016-03-31 08:40:07