util.BitSet: practical reference
util.BitSet: practical reference: BitSet is a growable packed bit vector whose logical length is the highest set bit plus one, not its storage capacity.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
util.BitSet: practical reference: BitSet is a growable packed bit vector whose logical length is the highest set bit plus one, not its storage capacity.
java.util.Collection<E> describes a group of elements. Learn how to check size and emptiness and distinguish sequential from possibly parallel streams in Java SE 21.
java.util.Collections provides static collection operations. Learn sorting, element swapping, and unmodifiable and synchronized views in Java SE 21.
java.util.Comparator describes an ordering independently of the objects' class. It lets you combine keys, reverse direction, and handle null explicitly for both whole elements and their fields.
ArrayBlockingQueue is a thread-safe FIFO queue backed by a fixed-capacity array. It transfers elements between producers and consumers and lets callers choose between waiting and receiving an immediate operation result.
util.concurrent.atomic.AtomicBoolean: practical reference: AtomicBoolean provides atomic boolean reads, writes, compare-and-set, and memory-effect variants.
AtomicInteger provides atomic operations on a single int value shared between threads. Learn reading, writing, incrementing, and conditional updates, including the limits of atomicity.
AtomicLong holds one long value and provides atomic updates shared by threads. Its incrementAndGet() method increases the value by one and returns the updated result.
AtomicReference<V> provides atomic operations on one reference. Learn how get(), conditional compareAndSet(), and unconditional getAndSet() differ, and why object identity rather than content equality determines whether a conditional replacement succeeds.
LongAccumulator combines long values using a supplied function. It supports concurrent updates, but get() does not provide an atomic snapshot while updates are occurring.
LongAdder maintains a long sum updated by multiple threads. It suits statistics, but sum() does not provide an atomic snapshot, and resetting requires control over concurrent updates.
BlockingQueue<E> supports safe exchange of elements between threads, such as a producer and a consumer. It distinguishes operations that do not wait for space or elements, waiting operations, and timed variants. The example uses an ArrayBlockingQueue with capacity 1.
util.concurrent.Callable: practical reference: Callable<V> is a functional interface for a no-argument task that returns V and may throw Exception.
CompletableFuture<T> represents a future result and lets you connect dependent stages without blocking after every step. Learn transformations, composition, result combination, error recovery, and timeouts in Java SE 21.
util.concurrent.CompletionService: practical reference: CompletionService<V> separates task submission from retrieving Future results in completion order.
util.concurrent.CompletionStage: practical reference: CompletionStage<T> describes a computation stage that performs an action or computes a value when another stage completes.
ConcurrentHashMap lets multiple threads safely use a shared map. Atomic operations for a key do not, however, turn a sequence of calls into a transaction.
Learn ConcurrentLinkedQueue and its add, isEmpty, and poll methods for insertion, empty checks, and safe retrieval.
util.concurrent.CopyOnWriteArrayList: practical reference: CopyOnWriteArrayList<E> is a thread-safe list that copies its entire backing array on every mutation.
CountDownLatch coordinates threads: await() waits until countDown() calls reduce the count to zero. It supports waiting for a group of operations and guarantees visibility of earlier writes.
CyclicBarrier synchronizes a fixed number of participants at successive phase boundaries. Calling await() waits for the others; an optional action combines results before the next phase begins.
java.util.concurrent.Executor accepts Runnable tasks through execute. It separates task submission from execution policy; it guarantees neither a separate thread nor asynchronous execution.
java.util.concurrent.Executors provides factory methods for task executors. Executors.newFixedThreadPool limits the number of active worker threads, but not the queue size. Learn how to retrieve results and close the pool in Java SE 21.
ExecutorService separates task submission from execution management. Learn submit, bulk execution with invokeAll, and shutdown, including the distinction between requesting shutdown and waiting for termination.