Skip to main content

Java

Top 40 Java Concurrency Interview Questions and Answers (2026)

40 Java concurrency interview questions, from race conditions to ScopedValue's exact child-thread inheritance rules. The four trickiest get fresh, verified code and real captured output; the rest link to this site's own deep dives that already proved their claims.

CountDownLatch vs CyclicBarrier vs Phaser vs Semaphore in Java

CountDownLatch, CyclicBarrier, and Phaser implement the same three-round pipeline three ways - reuse semantics, dynamic registration, and a timeout that permanently breaks one of them but not the others. Semaphore solves a genuinely different problem.

synchronized vs ReentrantLock vs StampedLock: Benchmarks and a Decision Table

Three ways to guard the same counter, benchmarked with JMH on JDK 25: what the fair ReentrantLock's FIFO handoff actually costs under contention, why StampedLock's optimistic read wins a 9:1 read-heavy workload by over 20x, a real deadlock resolved live by tryLock's timeout, and a JDK21-vs-JDK25 side-by-side proving JEP 491 stopped synchronized from pinning virtual threads.

Gradle 9 for Spring Boot 4 Projects: Configuration Cache, Version Catalogs and Kotlin DSL

Gradle 9 removed several things that a typical Spring Boot 3 build script still uses, and it treats the configuration cache as the direction of travel. This article takes one small Spring Boot 4 project, written the way most Boot 3 projects were, runs it on Gradle 8 and Gradle 9, and fixes it step by step. Every error message below comes from a real run. You only need to have run ./gradlew build before. Terms such as configuration cache, version catalog and Kotlin DSL are explained where they first appear. Versions tested. Gradle 9.8.0 on JDK 25.0.4.1 and Gradle 8.14.3 on JDK 21, with Spring Boot 4.1.1, on 28 September 2026. Companion code: spring-boot-demo/gradle9.

What’s Coming in JDK 28: Value Classes Preview and Strict Field Initialization

JDK 28 will be released in March 2027, and its headline feature is one Java developers have waited a decade for: value classes, the first preview to come out of Project Valhalla. Early-access builds already exist, so instead of summarising a JEP page this article installs one and tries the features. You need to know what a Java record is and that == on two objects normally asks “is this the very same object?”. That question is exactly what value classes change. Status: early access, snapshot of 28 September 2026. Tested on OpenJDK 28-ea+17 (build of 24 September), compared with JDK 25.0.4.1. Everything here can change before general availability, and this article will be updated as JEP targets change. Nothing below is a recommendation to use preview features in production. Companion code: javademos/jdk28-preview.

Java 17 to Java 25 Migration Guide: The Direct Jump

Java 21 is the LTS most guides tell you to upgrade to. But plenty of teams are still on Java 17, and when they finally move, the sensible target is the next LTS, Java 25, skipping 21 entirely. That is a jump across eight releases, and the release notes for eight releases are not a reading list anyone wants. This article does something simpler. It takes small programs compiled once for Java 17, runs them unchanged on Java 17 and Java 25, and shows what differs — what now fails, what silently changes, what merely warns. Then it shows how to have the JDK’s own tools find the same problems in your code. You need to know how to run a Java program; nothing more. Versions and status. JDK 17.0.20.1 and JDK 25.0.4.1 (both Temurin), Maven 3.9, on a 2-CPU Linux machine. Java 25 is an LTS release. Spring Boot 4.1.1 for the framework rows. Everything below was run unless the text says it is a quotation from documentation. Companion code: javademos/migration-17-25.