How do you implement a barrier using CyclicBarrier in Java?
Learn how CyclicBarrier lets a fixed group of threads meet at a barrier, run a barrier action and repeat, with a full example and failure handling.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Learn how CyclicBarrier lets a fixed group of threads meet at a barrier, run a barrier action and repeat, with a full example and failure handling.
CountDownLatch makes one or more threads wait until a fixed number of tasks complete. See how countDown and await work, with examples, pitfalls and alternatives.
Use ReentrantReadWriteLock so many threads can read at once while writes stay exclusive. Includes a cache example, downgrading, fairness and alternatives.
Learn what ReentrantLock is, how it differs from synchronized, and how to use tryLock, fairness and Conditions safely with a complete tested example.
The Lock interface gives explicit control over thread synchronization. See ReentrantLock, tryLock, Condition, fairness and read-write locks, and when synchronized is enough.
The volatile keyword gives visibility and ordering between threads, not atomic updates. See when a volatile flag is enough and when to use atomics or locks.
A synchronized block lets one thread at a time run a critical section. See how it differs from synchronized methods, how to choose a lock and what to avoid.
Add the synchronized keyword to a method so only one thread runs it at a time on an object. Covers static locks, blocks and alternatives.
The synchronized keyword makes one thread at a time run guarded code and publishes its writes. Compare it with volatile, atomics and ReentrantLock.
Use OuterClass.this in a non-static inner class, pass a reference from a static nested class, and know how anonymous classes and lambdas differ.
A local inner class is a named class declared inside a method. See how it captures effectively final variables, how it differs from lambdas, and local records.
Declare a static nested class in Java, see what it can access, how it differs from an inner class, and when builders and nodes should use it.
The four nested class types in Java with runnable examples, a comparison table, and guidance on inner classes versus lambdas.
final restricts change, finally runs cleanup after try, and finalize() is a deprecated GC hook. See examples, try-with-resources and the Cleaner replacement.
Use static final to declare a constant in Java. See naming rules, how final differs from immutability, and when to choose enums or configuration.
The final keyword prevents reassigning variables, overriding methods and extending classes. Learn each use and why it does not make objects immutable.
Implement Java cloning with Cloneable and clone(), understand shallow and deep copies, and see why copy constructors and records are often better.
Set JMS message priority from 0 to 9 in Spring Boot, enable priority ordering in ActiveMQ, and know when separate queues work better.
Use JmsTransactionManager and transacted listener containers so JMS messages commit or roll back together, and learn why a database write needs an outbox.
ActiveMQ has no shovel element. Use a network connector, an Artemis bridge or a Camel route to forward JMS messages between brokers, with Spring Boot code for both sides.