intermediateMultithreading & Concurrency345 of 436

Can ReentrantLock be fair? What is the performance trade-off?

Tests whether you know new ReentrantLock(true) enforces strict FIFO ordering to prevent thread starvation, at the cost of throughput -- fair locks have higher overhead and lower overall throughput than the default barging (unfair) mode under contention.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

← Back to all Core Java questions