Back to skills
SKILL.md
Java Concurrency
ASecurityImplement modern concurrency with Virtual Threads and Structured Concurrency in Java. Use when implementing Java Virtual Threads (Java 21), Structured Concurrency with StructuredTaskScope, CompletableFuture pipelines, or debugging race conditions.
- 549 stars
- 0 votes
- 0 copies
- 1 view
- Added June 6, 2026
Security analysis
100/100Pro scans all 3 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill java-concurrency --agent claude-codeAre you the author of Java Concurrency?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-java-concurrency)---
name: java-concurrency
description: Implement modern concurrency with Virtual Threads and Structured Concurrency in Java. Use when implementing Java Virtual Threads (Java 21), Structured Concurrency with StructuredTaskScope, CompletableFuture pipelines, or debugging race conditions.
metadata:
triggers:
files:
- '**/*.java'
keywords:
- Thread
- Executor
- synchronized
- lock
- CompletableFuture
- StructuredTaskScope
- VirtualThread
- AtomicInteger
- async
- race condition
---
# Java Concurrency
## **Priority: P1 (HIGH)**
## Implementation Guidelines
- **Virtual Threads (Java 21)**: Use for high-throughput I/O. `Executors.newVirtualThreadPerTaskExecutor()`.
- **Structured Concurrency**: Use `StructuredTaskScope` to treat related tasks as 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 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)Files in this skill
- SKILL.md
- evals/evals.json
- references/structured-concurrency.md
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.