java-concurrency
Modern concurrency patterns using Virtual Threads and Structured Concurrency. Use when implementing Java Virtual Threads (Java 21), Structured Concurrency with StructuredTaskScope, CompletableFuture pipelines, or debugging race conditions. (triggers: **/*.java, Thread, Executor, synchronized, lock, CompletableFuture, StructuredTaskScope, VirtualThread, AtomicInteger, async, race condition)
Best use case
java-concurrency is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Modern concurrency patterns using Virtual Threads and Structured Concurrency. Use when implementing Java Virtual Threads (Java 21), Structured Concurrency with StructuredTaskScope, CompletableFuture pipelines, or debugging race conditions. (triggers: **/*.java, Thread, Executor, synchronized, lock, CompletableFuture, StructuredTaskScope, VirtualThread, AtomicInteger, async, race condition)
Teams using java-concurrency should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/java-concurrency/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How java-concurrency Compares
| Feature / Agent | java-concurrency | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Modern concurrency patterns using Virtual Threads and Structured Concurrency. Use when implementing Java Virtual Threads (Java 21), Structured Concurrency with StructuredTaskScope, CompletableFuture pipelines, or debugging race conditions. (triggers: **/*.java, Thread, Executor, synchronized, lock, CompletableFuture, StructuredTaskScope, VirtualThread, AtomicInteger, async, race condition)
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Java Concurrency ## **Priority: P1 (HIGH)** Modern concurrent programming emphasizing Virtual Threads (Loom) and safety. ## Implementation Guidelines - **Virtual Threads (Java 21)**: Use for high-throughput I/O. `Executors.newVirtualThreadPerTaskExecutor()`. - **Structured Concurrency**: Use `StructuredTaskScope` to treat related tasks as a single unit (Scope, Fork, Join). - **Immutability**: Share immutable data between threads to avoid race conditions. - **CompletableFuture**: Use for composing async pipelines (if not using Virtual Threads). - **Atomic Variables**: Use `AtomicInteger`, `LongAdder` for simple counters. - **Locks**: Prefer `ReentrantLock` / `ReadWriteLock` over `synchronized` for fine-grained control. - **Thread Safety**: Document `@ThreadSafe` or `@NotThreadSafe`. ## Anti-Patterns - **No new Thread()**: Use Executors or virtual threads; never create threads manually. - **No Pooling Virtual Threads**: Virtual threads are cheap; never pool them. - **No Blocking in synchronized**: Pins carrier thread (Loom pitfall); use ReentrantLock instead. - **No Shared Mutable State**: Share only immutable data between threads. - **No Thread.stop/suspend**: Deprecated; use interruption or cancellation instead. ## References - [StructuredTaskScope & VirtualThread Examples](references/structured-concurrency.md)
Related Skills
javascript-typescript-jest
Best practices for writing JavaScript/TypeScript tests using Jest, including mocking strategies, test structure, and common patterns.
java-springboot
Get best practices for developing applications with Spring Boot.
java-refactoring-remove-parameter
Refactoring using Remove Parameter in Java Language
java-refactoring-extract-method
Refactoring using Extract Methods in Java Language
java-mcp-server-generator
Generate a complete Model Context Protocol server project in Java using the official MCP Java SDK with reactive streams and optional Spring Boot integration.
java-junit
Get best practices for JUnit 5 unit testing, including data-driven tests
java-docs
Ensure that Java types are documented with Javadoc comments and follow best practices for documentation.
java-add-graalvm-native-image-support
GraalVM Native Image expert that adds native image support to Java applications, builds the project, analyzes build errors, applies fixes, and iterates until successful compilation using Oracle best practices.
create-spring-boot-java-project
Create Spring Boot Java Project Skeleton
go-concurrency
Use when writing concurrent Go code — goroutines, channels, mutexes, or thread-safety guarantees. Also use when parallelizing work, fixing data races, or protecting shared state, even if the user doesn't explicitly mention concurrency primitives. Does not cover context.Context patterns (see go-context).
javascript-typescript-typescript-scaffold
You are a TypeScript project architecture expert specializing in scaffolding production-ready Node.js and frontend applications. Generate complete project structures with modern tooling (pnpm, Vite, N
javascript-testing-patterns
Implement comprehensive testing strategies using Jest, Vitest, and Testing Library for unit tests, integration tests, and end-to-end testing with mocking, fixtures, and test-driven development. Use when writing JavaScript/TypeScript tests, setting up test infrastructure, or implementing TDD/BDD workflows.