java-concurrency

pluginagentmarketplace/custom-plugin-java · updated Apr 8, 2026

$npx skills add https://github.com/pluginagentmarketplace/custom-plugin-java --skill java-concurrency
0 commentsdiscussion
summary

Master Java concurrency patterns for thread-safe applications.

skill.md

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

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.852 reviews
  • Chaitanya Patil· Dec 8, 2024

    java-concurrency fits our agent workflows well — practical, well scoped, and easy to wire into existing repos.

  • Arjun Kim· Dec 8, 2024

    Keeps context tight: java-concurrency is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Omar Smith· Dec 4, 2024

    java-concurrency is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

  • Piyush G· Nov 27, 2024

    Registry listing for java-concurrency matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Hiroshi Ghosh· Nov 27, 2024

    java-concurrency has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Sophia Singh· Nov 23, 2024

    Solid pick for teams standardizing on skills: java-concurrency is focused, and the summary matches what you get after install.

  • Shikha Mishra· Oct 18, 2024

    java-concurrency reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Kwame Johnson· Oct 18, 2024

    Solid pick for teams standardizing on skills: java-concurrency is focused, and the summary matches what you get after install.

  • William Singh· Oct 14, 2024

    java-concurrency has been reliable in day-to-day use. Documentation quality is above average for community skills.

  • Yash Thakker· Sep 25, 2024

    java-concurrency is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.

showing 1-10 of 52

1 / 6