Semaphore vs ReentrantLock in Java: Key Differences
Semaphore vs ReentrantLock in Java compared with a table and code for ownership, reentrancy, IllegalMonitorStateException, conditions and when to use each.
Semaphore vs ReentrantLock in Java compared with a table and code for ownership, reentrancy, IllegalMonitorStateException, conditions and when to use each.
Use a Java Lock to let one thread at a time change shared data. Covers ReentrantLock with try-finally, tryLock() with a timeout, fair locks, ReadWriteLock, StampedLock, Condition and virtual threads.
Object level lock vs class level lock in Java with runnable proof that the two locks are independent, syntax variants, pitfalls and virtual thread notes.
Deadlock in Java explained with a deterministic example, jstack and ThreadMXBean detection, lock ordering, tryLock timeouts and interruptible recovery.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.