From ggcoder
You MUST invoke this when working with concurrent/multithreaded code, especially in GridGain/Ignite. Triggers: HashMap in shared context, race condition, thread-safe, synchronized, volatile, ConcurrentHashMap, deadlock, lock ordering, AtomicReference, executor, parallel streams. Invoke BEFORE suggesting thread-safety fixes.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ggcoder:concurrency-patternsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Severity**: Critical | **Confidence Threshold**: 80%
Severity: Critical | Confidence Threshold: 80%
Triggers:
When to use: Lazy initialization, singletons, cached computations
public class Lazy<T> {
private volatile Supplier<T> supplier;
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
private @Nullable T val;
public @Nullable T get() {
T v = val; // Single read into local
if (v == null) {
if (supplier != EMPTY) {
synchronized (this) {
if (supplier != EMPTY) { // Double-check
v = supplier.get();
val = v;
supplier = (Supplier<T>) EMPTY;
}
}
}
v = val;
}
return v;
}
}
Key points:
volatile on supplier for visibilityWhen to use: Any synchronized access to shared state
private final Object lock = new Object();
private volatile boolean cancelled = false;
public void doWork() {
synchronized (lock) {
if (cancelled) throw new CancelledException();
state = newState;
}
// Async work OUTSIDE lock
processAsync(state);
}
Anti-pattern: synchronized(this) exposes to external interference
When to use: Lifecycle/cancellation flags
private volatile boolean cancelled = false;
private volatile boolean finished = false;
this// Before
private boolean flag;
// After
private volatile boolean flag;
// Before
public synchronized void method() { ... }
// After
private final Object lock = new Object();
public void method() {
synchronized (lock) { ... }
}
npx claudepluginhub gridgain/ggcoderCreates structured, bite-sized implementation plans from specs or requirements before writing code. Useful for breaking down multi-step tasks into testable steps with file structure and task boundaries.