Skip to content

java-tutorials

33 Posts

How to Use CountDownLatch, CyclicBarrier and Semaphore

Build a stock-sync job in plain Java 21 and use CountDownLatch, CyclicBarrier and Semaphore each where it fits, with runnable checks and the traps I forced.

How to Implement the Observer Pattern in Java (Java 21)

Build a stock-alert system with the observer pattern in Java 21: a thread-safe subject, lambda listeners, safe unsubscribe, and 16 checks that prove it works.