
How to Use ReentrantLock and Condition Variables in Java
Use ReentrantLock for timed and interruptible locking and Condition for waiting on state, with a bounded buffer example and the unlock-in-finally rule.
Tag
223 posts

Use ReentrantLock for timed and interruptible locking and Condition for waiting on state, with a bounded buffer example and the unlock-in-finally rule.

Learn AssertJ: fluent assertions for values, strings, collections, exceptions and objects, soft assertions, custom messages and extracting fields.

Call other HTTP services from Quarkus with the REST Client: an annotated interface, configuration, headers, error mapping, timeouts and testing with mocks.

Use PrimeFaces dialogs in JSF: p:dialog with widgetVar, opening from the client or server, confirm dialogs, forms inside dialogs and common mistakes.

Test exceptions, log output and System.out in JUnit 5: assertThrows, checking messages and causes, capturing logs with Logback appenders and console output.

Set breakpoints, step through code, evaluate expressions, watch variables and use exception breakpoints in IntelliJ IDEA to find bugs faster.

Combine Struts 2 with Hibernate by opening a session per request in an interceptor or filter, keeping lazy loading working in JSPs, and managing transactions.

Deploy Micronaut to AWS Lambda as a function or an API: choose a handler, build a JVM or GraalVM native artifact, use SnapStart and cut cold starts.

Use OpenRewrite recipes with Maven to upgrade Java, Spring Boot and test libraries automatically, review the patch and chain recipes of your own.

Design API pagination, filtering and sorting: query parameters, offset versus cursor, allowed sort fields, response envelopes, links and limits in Spring.

Move from coarse roles to fine permissions in Spring Security with method security, custom bean checks, a meta annotation and tests for allow and deny.

Use ReentrantReadWriteLock when reads outnumber writes and StampedLock for optimistic reads, with the traps of lock upgrades, reentrancy and measuring first.