125-java-concurrency

Featured

Use when you need to apply Java concurrency best practices — including thread safety fundamentals, ExecutorService thread pool management, concurrent design patterns like Producer-Consumer, asynchronous programming with CompletableFuture, immutability and safe publication, deadlock avoidance, virtual threads, structured concurrency, scoped values, backpressure, cancellation discipline, and observability for concurrent systems. This should trigger for requests such as Review Java code for concurrency; Review Java code for thread safety; Fix race conditions in Java concurrency code; Choose ExecutorService or virtual threads in Java; Improve synchronization and shared mutable state handling; Apply structured concurrency for related Java subtasks. Part of Plinth Toolkit

AI & Automation 439 stars 92 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 92/100

Stars 20%
88
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Java rules for Concurrency objects Identify and apply Java concurrency best practices to improve thread safety, scalability, and maintainability by using modern `java.util.concurrent` utilities and virtual threads. **What is covered in this Skill?** - Thread safety fundamentals: `ConcurrentHashMap`, `AtomicInteger`, `ReentrantLock`, `ReadWriteLock`, Java Memory Model - `ExecutorService` thread pool configuration: sizing, keep-alive, bounded queues, rejection policies, graceful shutdown - Producer-Consumer and Publish-Subscribe patterns with `BlockingQueue` - `CompletableFuture` for non-blocking async composition (`thenApply`/`thenCompose`/`exceptionally`/`orTimeout`) - Immutability and safe publication (`volatile`, static initializers) - Lock contention and false-sharing performance optimization - Virtual threads (`Executors.newVirtualThreadPerTaskExecutor()`) for I/O-bound scalability - Structured Concurrency (`StructuredTaskScope`) for related subtasks in Java 27 preview - `ScopedValue` over `ThreadLocal` for immutable cross-task data - Cooperative cancellation and `InterruptedException` discipline - Backpressure with bounded queues and `CallerRunsPolicy` - Deadlock avoidance via global lock ordering and `tryLock` with timeouts - ForkJoin/parallel-stream discipline for CPU-bound work - Virtual-thread pinning detection (JFR `VirtualThreadPinned`) - Thread naming and `UncaughtExceptionHandler` observability - Fit-for-purpose primitives: `LongAdder`, `CopyOnWriteArrayList...

Details

Author
jabrena
Repository
jabrena/plinth
Created
1 years ago
Last Updated
today
Language
Java
License
Apache-2.0

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category

Code & Development Listed

java-concurrency-review

Reviews Java code for thread safety, race conditions, deadlocks, and Java 21 virtual thread compatibility. Use when user asks to "review concurrency", "is this thread safe", "check for race conditions", "concurrency issues", or "virtual thread compatible".

0 Updated today
limited-grisaille833
Code & Development Listed

thalarch-jvm-concurrency

Java/JVM concurrency and asynchronous-execution specialist. Use when code touches threads, executors, virtual threads, CompletableFuture, locks, atomics, shared mutable state, ThreadLocal or ScopedValue, Spring @Async, blocking work, cancellation, or thread-safety/performance risks. Requires version-aware API verification and evidence for race/deadlock/performance claims.

2 Updated 5 days ago
LUC4N3X
AI & Automation Listed

concurrent-collections-and-synchronizers

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).

2 Updated 5 days ago
robsonkades