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/...
Verwenden Sie diese Option, wenn Sie Best Practices für Java-Parallelität anwenden müssen – einschließlich Thread-Sicherheitsgrundlagen, ExecutorService-Thread-Pool-Management, gleichzeitige Entwurfsmuster wie Producer-Consumer, asynchrone Programmierung mit CompletableFuture, Unveränderlichkeit und sichere Veröffentlichung, Deadlock-Vermeidung, virtuelle Threads und strukturierte Parallelität, Bereichswerte, Gegendruck, Abbruchdisziplin und Beobachtbarkeit für gleichzeitige Systeme. Teil des Skills-for-Java-Projekts Quelle: jabrena/cursor-rules-java.