Pessimistic lock, that is, if one person accesses this line, other people's access will be blocked. See the LockMode class for details
Optimistic locking, everyone can access it at the same time. Only one person will succeed in the end. Others can complete it by repeatedly retrying the transaction. This is usually achieved by adding a field version to the table. Please refer to here for details
Pessimistic lock, that is, if one person accesses this line, other people's access will be blocked. See the LockMode class for details
Optimistic locking, everyone can access it at the same time. Only one person will succeed in the end. Others can complete it by repeatedly retrying the transaction. This is usually achieved by adding a field version to the table. Please refer to here for details
Don’t think about solving this problem at the JVM level, because it will just stop in a cluster environment.
You can refer to the optimistic lock design of the database, which has been discussed before.