Identify and apply Java concurrency best practices to improve thread safety, scalability, and maintainability by using modern java.util.concurrent utilities, virtual threads, and structured concurrency.
Prerequisites: Run ./mvnw compile or mvn compile before applying any change. If compilation fails, stop immediately — compilation failure is a blocking condition that prevents any further processing.
Core areas: 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 concurrent design patterns (BlockingQueue), CompletableFuture for non-blocking async composition (thenApply/thenCompose/exceptionally/...
Java 同時実行のベスト プラクティスを適用する必要がある場合に使用します。これには、スレッド セーフティの基礎、ExecutorService スレッド プール管理、Producer-Consumer などの同時実行設計パターン、CompletableFuture による非同期プログラミング、不変性と安全なパブリケーション、デッドロック回避、仮想スレッドと構造化同時実行性、スコープ値、バックプレッシャー、キャンセル規律、同時システムのオブザーバビリティが含まれます。 Skills-for-Java プロジェクトの一部 ソース: jabrena/cursor-rules-java。