125-java-concurrency

Solid

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, scoped values, backpressure, cancellation discipline, and observability for concurrent systems. This should trigger for requests such as Review Java code for concurrency. Part of cursor-rules-java project

AI & Automation 404 stars 80 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 93/100

Stars 20%
87
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 - `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`, `StampedLock`, `Semaphore`, `CountDownLatch`, `Phaser` **Scope:** The reference is or...

Details

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

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category