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, неизменяемость и безопасную публикацию, предотвращение взаимоблокировок, виртуальные потоки и структурированный параллелизм, значения области действия, противодавление, дисциплину отмены и наблюдаемость для параллельных систем. Часть проекта «Навыки для Java» Источник: jabrena/cursor-rules-java.