Skip to content
Back to skills

Java Concurrency

ASecurity

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)

  • 67 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 10, 2026
developmentjavadebugging

Security analysis

A100/100

Scanned November 10, 2026

npx -y skills add ComeOnOliver/skillshub --skill java-concurrency --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Java Concurrency?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Java Concurrency
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/comeonoliver-java-concurrency/badge)](https://www.skillsdirectory.com/skills/comeonoliver-java-concurrency)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: java-concurrency
description: "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)"
---

# 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)

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.