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. Part of the skills-for-java project
88
85%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
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?
ConcurrentHashMap, AtomicInteger, ReentrantLock, ReadWriteLock, Java Memory ModelExecutorService thread pool configuration: sizing, keep-alive, bounded queues, rejection policies, graceful shutdownBlockingQueueCompletableFuture for non-blocking async composition (thenApply/thenCompose/exceptionally/orTimeout)volatile, static initializers)Executors.newVirtualThreadPerTaskExecutor()) for I/O-bound scalabilityScopedValue over ThreadLocal for immutable cross-task dataInterruptedException disciplineCallerRunsPolicytryLock with timeoutsVirtualThreadPinned)UncaughtExceptionHandler observabilityLongAdder, CopyOnWriteArrayList, StampedLock, Semaphore, CountDownLatch, PhaserScope: The reference is organized by examples (good/bad code patterns) for each core area. Apply recommendations based on applicable examples.
Before applying any concurrency changes, ensure the project compiles. If compilation fails, stop immediately — compilation failure is a blocking condition. After applying improvements, run full verification.
./mvnw compile or mvn compile before applying any change./mvnw clean verify or mvn clean verify after applying improvementsFor detailed guidance, examples, and constraints, see references/125-java-concurrency.md.
7772a1b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.