← ClaudeAtlas

concurrent-collections-and-synchronizerslisted

Choosing between the members of java.util.concurrent once the family is settled, and the parameter that makes it correct: which BlockingQueue and which of its four insert and remove forms, which ConcurrentHashMap atomic replaces a compound action, copy-on-write's cost, latch versus barrier versus phaser versus semaphore, the Condition await loop, and ReentrantLock versus ReentrantReadWriteLock versus StampedLock. Use when computeIfAbsent loads from a database, when IllegalStateException "Recursive update" is thrown, when new LinkedBlockingQueue<>() appears in a producer, when a thread parks in CountDownLatch$Sync or every worker sits in CyclicBarrier.dowait, when await() sits under an if, or when a read lock is upgraded to a write lock. Not the thread-safety contract (java-thread-safety-contracts), executor lifecycle (executors-and-task-lifecycle), limit sizing (concurrency-limiting-and-bulkheads), CAS loops (lock-free-patterns), monitor contention (lock-inflation), or happens-before (java-memory-model).
robsonkades/agent-skills · ★ 2 · AI & Automation · score 75
Install: claude install-skill robsonkades/agent-skills
# Concurrent Collections and Synchronizers ## Purpose Once "use a concurrent collection", "use a queue" or "use a limit" is the decision, this is the next one: **which member of the family, with which parameter, and what breaks when it is wrong.** These failures are rarely exceptions — a consumer that idles with work queued, a limit of 8 that admits 12, a latch nobody counts down, a heap dump full of queue nodes. The _rule_ that a thread-safe collection does not make a sequence atomic belongs to java-thread-safety-contracts; the mechanism it implies is here. Baseline **Java 25**; vendor support status and version-sensitive claims must be checked separately. Before applying that authoring baseline, inspect the target compiler release/toolchain, deployed JDK/vendor/build and existing dependencies. Do not upgrade or enable preview merely to apply this skill. `StructuredTaskScope` is preview in Java 25; route to structured-concurrency for its version-specific API and compiler/runtime flags, and use existing stable coordination APIs when preview is not authorized. ## Workflow 1. **Name the admission policy before choosing an implementation.** If overload can occur, state the capacity or explain why an intrinsically unbounded structure is safe and bounded elsewhere. 2. **Pick the member from the tables below and write down the cost accepted.** A choice with no stated cost was not made. 3. **Pick the exact method form.** `offer(e, timeout, unit)` not `add`; `while` not `i