Skip to content

Latest commit

 

History

History
5 lines (3 loc) · 811 Bytes

lock.md

File metadata and controls

5 lines (3 loc) · 811 Bytes

A lock Back

A lock or mutex(互斥體) is a mechanism in software engineering to avoid accessing a DB resource in parallel when there are many threads of execution.

Optimistic Lock (乐观锁) means that the DB assumes any accessing won't modify the data, and it won't lock after your assessment, while Pessimistic Lock (悲观锁) means reversely. Many types of locks implemented in Java almost belong to a pessimistic one like a Spinlock (自旋锁), Mutual Exclusion (互斥锁), Reentrant mutex (可重入互斥锁), Readers-writer lock (读写锁).