Skip to main content

Java Regex Tutorial: Pattern, Matcher, Groups, Lookarounds and ReDoS

A beginner-first guide to java.util.regex: Pattern and Matcher, named groups, flags, lookarounds and replaceAll with a lambda, then the failure mode. Measured on JDK 25: which patterns still blow up exponentially, what the JDK already defuses, and fixes that work (rewriting, possessive quantifiers, atomic groups, a CharSequence timeout, input limits).

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.

Spring Kafka 3 to 4 Migration Guide

Moving a Spring application from Spring Kafka 3 to 4 looks like a version bump. It is three changes at once: the Kafka client itself jumps to 4.x, Spring Boot 4 stops configuring Kafka unless you use a new starter, and the JSON serializer you probably use is built on a Jackson that Boot 4 no longer puts on your classpath. This article migrates one small app and shows what each of those does when it goes wrong. You need to know what a Kafka topic, a producer and a consumer are. Everything else is explained as it appears. Versions tested. Before: Spring Boot 3.5.16, Spring Kafka 3.3.16, kafka-clients 3.9.2, JDK 21. After: Spring Boot 4.1.1, Spring Kafka 4.1.1 (latest GA), kafka-clients 4.2.1, JDK 25.0.4.1. Spring Kafka 4.2.0-M1 and M2 are milestones and were not tested. Date: 28 September 2026. Companion code: spring-messaging-demo/kafka4-migration.