Examples

Page 36 of 50

Browse code examples

sqlSnippet

RANK Over Grouped Totals

Rank grouped totals in one pass because window functions are evaluated after GROUP BY and can order by aggregate expressions like SUM(revenue).

goSnippet

Sync Cond Wait And Signal

Coordinate goroutines with sync.Cond: waiters park in a loop until a producer changes the guarded condition and calls Signal.

javaSnippet

CountDownLatch Readiness Gate

Gate startup on several one-shot signals with CountDownLatch and await(timeout), so boot either proceeds when all dependencies report ready or aborts.

javaSnippet

CyclicBarrier Phased Workers

Synchronize phased work with a reusable CyclicBarrier: workers await at the barrier each round and the last arrival runs the barrier action.

javaSnippet

WatchService Directory Events

Watch a directory for ENTRY_CREATE, ENTRY_MODIFY, and ENTRY_DELETE with WatchService, polling keys with a timeout and resetting them after each drain.

sqlSnippet

Named Window Clause Reuse

Name a window once in a WINDOW clause and reuse it with OVER w, appending frame clauses without repeating partition and order definitions.

typescriptSnippet

Async Disposal With await using

Release async resources deterministically with await using and Symbol.asyncDispose, which runs when the block exits even if the body throws.

bashSnippet

Bash Array Bulk Operations

Manipulate indexed arrays safely with quoted expansion, slice and search builtins, and mapfile ingestion so filenames with spaces survive round trips.

goSnippet

Sync Once Lazy Singleton Init

Initialize expensive resources exactly once with sync.Once, keeping first-call latency on the caller and all later calls lock-free after the gate.

javaSnippet

Atomic Variables CAS Counter

Track concurrent metrics with AtomicLong and LongAdder, and drive a compare-and-set loop when the update depends on the previous value.