# java-concurrency

A skill that gives your coding agent a Java concurrency reference: threads, executors, locks, CompletableFuture and virtual threads.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 465 installs · ★ 41
- Author: pluginagentmarketplace
- License: LicenseRef-Proprietary · policy=link-only · description only; the file stays with the author
- Source: https://github.com/pluginagentmarketplace/custom-plugin-java/tree/HEAD/skills/java-concurrency/SKILL.md
- Updated: 2026-01-05
- HTML: https://affpapa.org/en/nevibecode/skills/java-concurrency

## What it does

The skill walks through Java concurrency from the ground up. Thread lifecycle, daemon versus user threads, interrupt handling, then `synchronized`, `volatile`, `ReentrantLock` and atomic operations. Executors come next: `ThreadPoolExecutor` configuration, `ForkJoinPool`, and virtual threads from Java 21. A separate section covers `CompletableFuture` — async execution, chaining, exception handling.

Two reference tables do most of the practical work. One sizes thread pools: for CPU-bound work it suggests the core count, for I/O-bound work a formula based on the wait-to-compute ratio. The other maps symptoms to causes — deadlock from circular locking, race conditions from missing synchronization, thread starvation from unfair scheduling. For stuck processes it lists `jstack -l <pid>` and `jcmd <pid> Thread.print`.

The `java_version` parameter defaults to `21`, so the virtual thread examples assume that release. On an older JDK that section will not compile, which is worth checking before you let the agent touch your code. The skill is invoked with `Skill("java-concurrency")`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-java --skill java-concurrency -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/java-concurrency/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/java-concurrency/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-java --skill java-concurrency -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/java-concurrency/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-java --skill java-concurrency -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/java-concurrency/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install pluginagentmarketplace/custom-plugin-java java-concurrency
```

2. **Manually: put the files in place**
- File: `.github/skills/java-concurrency/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-java --skill java-concurrency -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/pluginagentmarketplace/custom-plugin-java --path skills/java-concurrency
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/java-concurrency/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add pluginagentmarketplace/custom-plugin-java --skill java-concurrency -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/pluginagentmarketplace/custom-plugin-java/tree/HEAD/skills/java-concurrency/SKILL.md

## When to use it
- write a thread-safe class without race conditions
- size a thread pool for the actual workload
- move a chain of calls onto `CompletableFuture`
- diagnose a hang from a thread dump
- migrate from platform threads to virtual threads on Java 21

## Example prompts
- Review this class for race conditions and tell me where a `ReentrantLock` belongs
- Configure a `ThreadPoolExecutor` for I/O-bound work and explain the pool size
- Rewrite these sequential calls as `CompletableFuture` with a timeout

## Similar
- [125-java-concurrency](https://affpapa.org/en/nevibecode/skills/125-java-concurrency.md) — skill · 402 installs
- [java-code-review](https://affpapa.org/en/nevibecode/skills/java-code-review.md) — skill · 1000 installs
- [m07-concurrency](https://affpapa.org/en/nevibecode/skills/m07-concurrency.md) — skill · 3500 installs
- [csharp-concurrency-patterns](https://affpapa.org/en/nevibecode/skills/csharp-concurrency-patterns.md) — skill · 1600 installs
- [go-concurrency](https://affpapa.org/en/nevibecode/skills/go-concurrency.md) — skill · 1300 installs
- [asyncio-concurrency-patterns](https://affpapa.org/en/nevibecode/skills/asyncio-concurrency-patterns.md) — skill · 489 installs

From the same set: [pluginagentmarketplace/custom-plugin-java](https://affpapa.org/en/nevibecode/by/pluginagentmarketplace/custom-plugin-java.md) — 4 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
