본문으로 건너뛰기
cccskills
무료GitHub에 공개

125-java-concurrency

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 and structured concurrency, scoped values, backpressure, cancellation discipline, and observability for concurrent systems. Part of the skills-for-java project

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md4.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

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, virtual threads, and structured concurrency.

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/orTimeout), immutability and safe publication (volatile, static initializers), lock contention and false-sharing performance optimization, virtual threads (Executors.newVirtualThreadPerTaskExecutor()) for I/O-bound scalability, StructuredTaskScope for lifecycle-scoped task management, 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, and fit-for-purpose primitives (LongAdder, CopyOnWriteArrayList, StampedLock, Semaphore, CountDownLatch, Phaser).

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.

Multi-step scope: Step 1 validates the project compiles. Step 2 analyzes existing concurrency patterns and categorizes issues by impact (CRITICAL, MAINTAINABILITY, PERFORMANCE, SCALABILITY). Step 3 applies thread safety fundamentals — replacing unsafe collections with java.util.concurrent equivalents and atomic classes. Step 4 refactors thread pool management to use properly configured ExecutorService instances with bounded queues and rejection policies. Step 5 implements concurrent design patterns (Producer-Consumer via BlockingQueue, Publish-Subscribe). Step 6 migrates asynchronous operations to CompletableFuture with proper chaining and timeout handling. Step 7 adopts modern Java concurrency features — virtual threads for I/O-bound tasks, StructuredTaskScope for related task groups, and ScopedValue instead of ThreadLocal. Step 8 enforces cancellation and interruption discipline — never swallowing InterruptedException, using Future.cancel(true), and preferring lockInterruptibly. Step 9 adds backpressure and overload protection — bounded queues, semaphores/bulkheads, and CallerRunsPolicy. Step 10 eliminates deadlock risks via lock ordering, minimized lock scope, and tryLock with timeouts. Step 11 adds observability — named threads, UncaughtExceptionHandler, JFR metrics, and structured logging. Step 12 runs ./mvnw clean verify to confirm all tests pass after changes.

Before applying changes: Read the reference for detailed good/bad examples, constraints, and safeguards for each concurrency pattern.

Reference

For detailed guidance, examples, and constraints, see references/125-java-concurrency.md.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

[00] META. Orchestrate skills into dynamic chains for complex tasks. Analyzes the task, discovers available skills, builds an optimal chain, explains why each skill is needed, and executes step-by-step with user confirmation. Use for any complex task requiring multiple thinking/research/analysis steps. Triggers on "plan this", "how to approach", "what's the strategy", "build a plan", or any multi-step problem requiring skill orchestration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

MikeCheng1208의 스킬 모두 보기

이 스킬의 문제 신고