Files
java-core-examples/locks/output/03-trylock-timeout-deadlock-avoidance.txt
asmhatre 32b8067ecf locks: synchronized vs ReentrantLock vs StampedLock companion code
JMH throughput sweep (1-64 threads), 9:1 read-heavy @Group benchmark,
tryLock(timeout) deadlock-avoidance demo, and a JDK21-vs-JDK25 JEP 491
virtual-thread-pinning comparison. Also promotes LICENSE to repo root
now that a second module exists.
2026-09-30 06:04:50 +00:00

10 lines
622 B
Plaintext

$ java -cp target/classes com.ankurm.locks.TryLockTimeoutDemo
Thread-2: timed out waiting for second lock on attempt 1 - backing off and retrying.
Thread-1: timed out waiting for second lock on attempt 1 - backing off and retrying.
Thread-2: timed out waiting for second lock on attempt 2 - backing off and retrying.
Thread-1: timed out waiting for second lock on attempt 2 - backing off and retrying.
Thread-2: timed out waiting for second lock on attempt 3 - backing off and retrying.
Thread-1: acquired both locks on attempt 3.
Thread-2: acquired both locks on attempt 4.
Both threads finished in 808 ms - no deadlock.