java-concurrency

Installation
SKILL.md

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.
Related skills
Installs
1
GitHub Stars
488
First Seen
Apr 1, 2026