util.concurrent.Flow: practical reference
util.concurrent.Flow: practical reference: Flow groups Reactive Streams-compatible Publisher, Subscriber, Subscription, and Processor interfaces with demand control.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
util.concurrent.Flow: practical reference: Flow groups Reactive Streams-compatible Publisher, Subscriber, Subscription, and Processor interfaces with demand control.
Future<V> represents an asynchronous task result. Future.get retrieves the result, waiting if necessary, while Future.isDone checks completion, which does not necessarily mean success.
LinkedBlockingQueue is a thread-safe FIFO queue built from linked nodes. It supports an optional capacity bound and operations that wait for space or an element, making it useful for producer–consumer communication.
Condition lets a thread wait for a change to shared state protected by a Lock. Learn await, awaitNanos, signal, and signalAll, and why the state check belongs in a loop.
The java.util.concurrent.locks.Lock interface provides explicit control over locking. Learn the lock()/unlock() pair, the safe try/finally pattern, and an example using ReentrantLock to protect a shared counter.
ReadWriteLock exposes associated read and write locks: multiple readers can share access, while writing requires exclusive access. Learn readLock() and writeLock(), visibility guarantees, and safe lock release.
ReentrantLock provides mutual exclusion while allowing its owner to acquire the same lock repeatedly. It requires explicit release and also offers tryLock() and associated Condition objects.
util.concurrent.locks.ReentrantReadWriteLock: practical reference: ReentrantReadWriteLock provides a shared read lock and an exclusive write lock with reentrancy.
StampedLock provides exclusive writing, shared reading, and optimistic reading with validation.
ConcurrentModificationException reports a detected modification that an object's contract forbids. It can occur in a single thread; it is neither a synchronization mechanism nor a guaranteed bug detector.
Phaser is a reusable synchronization barrier with a variable number of participants. It lets tasks wait for a stage to finish and deregister when their work ends.
util.concurrent.ScheduledExecutorService: practical reference: ScheduledExecutorService schedules one-shot tasks after relative delays and recurring tasks periodically.
java.util.concurrent.Semaphore limits access using a permit counter. Learn blocking acquire(), nonblocking tryAcquire(), and safe permit return using release().
util.concurrent.StructuredTaskScope: practical reference: StructuredTaskScope<T> is a Java 21 preview API that confines concurrent subtask lifetimes to a structured scope.
util.concurrent.SubmissionPublisher: practical reference: SubmissionPublisher<T> asynchronously delivers non-null items to current Flow.Subscribers through an independent buffer per subscriber.
TimeUnit describes time units used in operations such as timeouts. It converts long values, truncating fractional parts or saturating on overflow.
Date represents an instant with millisecond precision. Learn to read it with getTime(), change it with setTime(long), and compare it with equals(Object).
java.util.Deque<E> describes a double-ended queue: elements can be added and removed at either end. The same interface supports a FIFO queue and a LIFO stack; the methods you choose determine the behavior.
DoubleSummaryStatistics collects the count, sum, minimum, maximum, and average of double values. accept adds a value, while combine merges statistics.
EnumMap stores keys from one enum type. The example demonstrates construction, insertion, lookup, size, and iteration in enum declaration order.
EnumSet stores constants of one enum type without duplicates. Learn to create sets with of and allOf and use the add, remove, and contains operations.
util.function.BiConsumer: practical reference: BiConsumer<T,U> is a functional operation that accepts two arguments, returns no result, and is normally intended for side effects.
util.function.BiFunction: practical reference: BiFunction<T,U,R> is a functional interface that maps two potentially different argument types to one result R.
util.function.BinaryOperator: practical reference: BinaryOperator<T> specializes BiFunction<T,T,T> so both operands and the result have the same type.