Locksmedium3-5 years

Why would you choose ReentrantLock over synchronized?

For tryLock (non-blocking or with a timeout), lockInterruptibly, fairness, multiple Conditions per lock, introspection, and because virtual threads unmount while blocked on it (before Java 24 they pin on synchronized). The cost: you must unlock() in finally, every time.

The lesson behind it →
More on Locks