Skip to content

java-21

13 Posts

How to Use ScheduledExecutorService for Periodic Tasks in Java

In financial systems built on Apache Kafka and Flink, background scheduling is everywhere: checking consumer lag every 30 seconds, expiring distributed locks after a payment SLA window, scheduledExecutorService is production-grade answer to all of this.

How to Use synchronized Blocks and Methods Correctly in Java

Learn how to use Java's synchronized keyword correctly — with real payment and banking examples covering race conditions, synchronized methods, blocks, deadlock-free transfers, double-checked locking, and virtual thread pitfalls. Covers Java 8 through 21

How to Use CompletableFuture for Async Programming in Java

Learn how to use Java's CompletableFuture for async programming — with real payment pipeline examples covering supplyAsync, thenCompose, thenCombine, error handling, and custom thread pools. Covers Java 8, 9, and 21.

How to Use ScheduledExecutorService for Periodic Tasks in Java

Learn how to use Java's ScheduledExecutorService for periodic tasks — with real Kafka and payment pipeline examples covering scheduleAtFixedRate, scheduleWithFixedDelay, exception handling, graceful shutdown, and virtual threads. Covers Java 8 through 21.

ThreadLocal Goes Missing Inside StructuredTaskScope

A ThreadLocal that worked fine in a thread pool returns null the moment a virtual thread forks a subtask. Here's the mechanism, and what actually fixes it.

Java InvalidClassException: local class incompatible

InvalidClassException: local class incompatible means the stream's serialVersionUID no longer matches your class. Here is why it drifted, and how to fix it without losing data.