← スキル一覧に戻る

java-concurrency
by pluginagentmarketplace
Java Development Plugin
⭐ 2🍴 0📅 2026年1月24日
SKILL.md
name: java-concurrency description: Master Java concurrency - threads, executors, locks, CompletableFuture, virtual threads sasmp_version: "1.3.0" version: "3.0.0" bonded_agent: 02-java-advanced bond_type: PRIMARY_BOND allowed-tools: Read, Write, Bash, Glob, Grep
Parameter Validation
parameters: concurrency_model: type: string enum: [threads, executors, virtual_threads, reactive] java_version: type: string default: "21"
Java Concurrency Skill
Master Java concurrency patterns for thread-safe applications.
Overview
This skill covers concurrency from basic threads to virtual threads (Java 21+), including thread pools, synchronization, and CompletableFuture.
When to Use This Skill
Use when you need to:
- Write thread-safe code
- Implement parallel processing
- Use async programming patterns
- Tune thread pools
- Debug concurrency issues
Topics Covered
Thread Management
- Thread lifecycle and states
- Daemon vs user threads
- Interrupt handling
Synchronization
- synchronized, volatile
- Lock interfaces (ReentrantLock)
- Atomic operations
Executors
- ThreadPoolExecutor configuration
- ForkJoinPool
- Virtual Threads (Java 21+)
CompletableFuture
- Async execution
- Chaining and composition
- Exception handling
Quick Reference
// Virtual Threads (Java 21+)
try (var executor = Executors.newVirtualThreadPerTaskExecutor()) {
IntStream.range(0, 10_000).forEach(i ->
executor.submit(() -> processRequest(i)));
}
// CompletableFuture composition
CompletableFuture<Result> result = fetchUser(id)
.thenCompose(user -> fetchOrders(user.id()))
.thenApply(orders -> processOrders(orders))
.exceptionally(ex -> handleError(ex))
.orTimeout(5, TimeUnit.SECONDS);
// Thread pool configuration
ThreadPoolExecutor executor = new ThreadPoolExecutor(
10, 50, 60L, TimeUnit.SECONDS,
new ArrayBlockingQueue<>(1000),
new ThreadPoolExecutor.CallerRunsPolicy()
);
// Lock with timeout
ReentrantLock lock = new ReentrantLock();
if (lock.tryLock(1, TimeUnit.SECONDS)) {
try {
// critical section
} finally {
lock.unlock();
}
}
Thread Pool Sizing
| Workload | Formula | Example |
|---|---|---|
| CPU-bound | cores | 8 threads |
| I/O-bound | cores * (1 + wait/compute) | 80 threads |
Troubleshooting
| Problem | Cause | Solution |
|---|---|---|
| Deadlock | Circular lock | Lock ordering, tryLock |
| Race condition | Missing sync | Add locks/atomics |
| Thread starvation | Unfair scheduling | Fair locks |
Debug Commands
jstack -l <pid> > threaddump.txt
jcmd <pid> Thread.print
Usage
Skill("java-concurrency")
スコア
総合スコア
60/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です