|
|
KLOUDLY ACADEMY
The Kloudly Letter
|
Issue #2
2026-09-28
|
|
|
Friendly, practical Java & Spring news for professional developers. No fluff.
|
|
1. Latest from Kloudly Academy
|
|
|
|
|
|
|
|
|
Use Thread.join() to Wait for Another Thread to Finish
Need a result from a worker thread before moving on? Call worker.join() after starting it. The current thread waits for the worker to finish, so the next line can safely use the work it produced.
In the example below, main starts a worker, waits for it, then prints the result. If you use a timed call such as join(1000), check whether the worker is still alive before assuming it finished. join() can throw InterruptedException, so handle or propagate it.
|
public class JoinExample {
public static void main(String[] args) throws InterruptedException {
StringBuilder result = new StringBuilder();
Thread worker = new Thread(() -> {
try {
Thread.sleep(200);
result.append("background work complete");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
worker.start();
worker.join();
System.out.println(result);
}
}
|
|
Takeaway:
Call Thread.join() when the current thread must wait for another thread to finish before continuing.
Read more →
|
|
|
|
|
|
Do Not Use ArrayList for Shared Mutable State Without Synchronization
What would you improve in this code?
|
|
Before
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
class EventBus {
private final List<Consumer<String>> subscribers = new ArrayList<>();
public void subscribe(Consumer<String> subscriber) {
subscribers.add(subscriber);
}
public void publish(String event) {
for (Consumer<String> subscriber : subscribers) {
subscriber.accept(event);
}
}
}
|
|
What’s the issue?
EventBus is likely accessed by multiple threads, but both modification and iteration of the ArrayList are unsynchronized. A subscription concurrent with publish can cause ConcurrentModificationException, lost updates, or other unsafe behavior.
|
|
After
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Consumer;
class EventBus {
private final List<Consumer<String>> subscribers = new CopyOnWriteArrayList<>();
public void subscribe(Consumer<String> subscriber) {
subscribers.add(subscriber);
}
public void publish(String event) {
for (Consumer<String> subscriber : subscribers) {
subscriber.accept(event);
}
}
}
|
|
Why it’s better:
CopyOnWriteArrayList provides thread-safe updates and iteration over a stable snapshot, which is a good fit when events are published frequently and subscriptions change rarely. For other access patterns, use appropriate synchronization or another concurrent collection rather than exposing an unsynchronized ArrayList to multiple threads.
Read more →
|
|
|
|
|
The Arrival of Java 27!
— Java
JDK 27 is now generally available for developers, enterprises, and end-users. This marks the official release of the latest Java version and is the primary entry point for teams evaluating adoption.
Why it matters: A new JDK release can introduce language, runtime, and platform changes that affect builds, deployment, compatibility, and upgrade planning in production environments.
JDK 27 Security Enhancements
— Java
This article highlights the most notable security-related changes in JDK 27 and groups them by areas such as cryptography and TLS. It also points readers to the JDK 27 release notes for additional details.
Why it matters: Security updates are especially relevant for production Java applications because they can change defaults, protocols, or crypto behavior that directly impacts secure communication and compliance.
Spring AI and TypeSafe Jev: Fast, Cheap, Structured Decisions
— Spring, September 21, 2026
A new Spring AI Community integration uses TypeSafe Jev to answer typed questions for classification, scoring, routing, and checking model responses. The article shows how to combine these decisions with Spring AI advisors and evaluators.
Why it matters: Developers can add structured checks to AI workflows without parsing generated text, while keeping open-ended answers in their existing chat model.
|
|
|
|
5. Next on Kloudly Academy
|
|
|
Next up: two articles on getting results from concurrent Java tasks. We’ll cover Callable, which lets a task return a value or throw an exception, and Future, which lets you retrieve the result, check progress, or cancel the task.
|
|
You’re receiving this because you subscribed to Kloudly Academy.
•
Unsubscribe
•
Update preferences
|