Language-Level Concurrency and Multithreading Questions
Per-language and per-runtime concurrency: the threading and async APIs each language provides (goroutines and channels in Go, threads and executors in Java, async/await runtimes, C++ std::thread and atomics), each language's memory model, and the idioms for coordinating shared state safely in that language. Covers choosing and using a language's concurrency primitives correctly; OS-level scheduling, synchronization theory, and deadlock internals live in Operating Systems & Systems Programming.
A Go service leaks goroutines because some goroutines block on network reads and never exit on shutdown. Propose and describe code changes to ensure deterministic shutdown and that goroutines exit: include use of context.Context, listener.Close(), deadlines, WaitGroup patterns, and how to verify no leaks remain in production.
In Go, write a function that runs multiple independent checks in parallel, returns all failures in a single error value, and preserves enough context for an operator to diagnose the problem quickly. The function should respect context cancellation by stopping new work and allowing in-flight checks to exit promptly.
Write a concurrent log processor in Go that reads from multiple log files and extracts metrics using a worker pool. Requirements: preserve per-file line order when sending extracted records to downstream processing, support backpressure if downstream is slow, and avoid processing the same line twice on restarts if check-pointed offsets are used.
In Go, implement a worker pool that processes a list of jobs concurrently and returns the results in the same order as the input. The pool should limit concurrency to a fixed number of workers and avoid leaking goroutines if one job fails. Describe the data structures you would use and why.
In Go, implement a fan-out/fan-in pipeline that sends the same request to multiple backends, returns the first successful response, and cancels the remaining work immediately. The solution must not leak goroutines, must collect all errors if every backend fails, and must respect a parent context.
That is every published Language-Level Concurrency and Multithreading question for Site Reliability Engineer (SRE) so far. Browse the other topics in this category, or practice this one interactively.