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 423 stars 89 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 - 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".

1 Updated yesterday
limited-grisaille833
AI & Automation Featured

142-java-functional-programming

Use when you need to apply functional programming principles in Java — including writing immutable objects and Records, pure functions, functional interfaces, lambda expressions, Stream API pipelines, Optional for null safety, function composition, higher-order functions, pattern matching for instanceof and switch, sealed classes/interfaces for controlled hierarchies, Stream Gatherers for custom operations, currying/partial application, effect boundary separation, and concurrent-safe functional patterns. This should trigger for requests such as Improve the code with Functional Programming; Apply Functional Programming; Refactor the code with Functional Programming; Refactor Java code to use streams or Optionals safely; Improve immutability and pure functions in Java. Part of Plinth Toolkit

423 Updated today
jabrena
AI & Automation Featured

126-java-exception-handling

Use when you need to apply Java exception handling best practices — including using specific exception types, managing resources with try-with-resources, securing exception messages, preserving error context via exception chaining, validating inputs early with fail-fast principles, handling thread interruption correctly, documenting exceptions with @throws, enforcing logging policy, translating exceptions at API boundaries, managing retries and idempotency, enforcing timeouts, attaching suppressed exceptions, and propagating failures in async/reactive code. This should trigger for requests such as Exception handling; Use try-with-resources in Java code; Create exception chaining in Java code; Apply fail-fast validation in Java code; Review Java exception taxonomy and propagation. Part of Plinth Toolkit

423 Updated today
jabrena