Language-Level Concurrency and Multithreading Questions

Per-language and per-runtime concurrency: the threading and async APIs each language and platform provides (goroutines, channels, worker pools and pipelines in Go, threads, executors, ThreadPoolExecutor tuning and CompletableFuture in Java, Kotlin coroutines, dispatchers, Flow and structured concurrency, Swift GCD with queues and QoS, DispatchGroup, OperationQueue, actors and async/await, Android Handler/Looper, HandlerThread and thread pools, Flutter isolates, C++ std::thread and atomics, Python threads versus multiprocessing versus asyncio tasks, gather and graceful shutdown), each language's memory model and visibility guarantees (Java happens-before and volatile, C++11 memory orders such as relaxed, acquire and release, Objective-C and Swift atomic versus nonatomic), mobile main-thread rules and JNI thread attachment, cancellation and shutdown idioms, and the idioms for coordinating shared state safely in that language, including thread-safe caches, singletons and bounded queues. Also covers reproducing, testing and diagnosing races and deadlocks in a specific language or app, and migrating callback, GCD or thread-pool code to structured concurrency. Covers choosing and using a language's concurrency primitives correctly. Boundary: general synchronization theory, deadlock and lock-free algorithm internals, OS scheduling, database isolation levels, and callback or event-loop architecture are covered elsewhere.

MediumTechnical
26 practiced

A Python web service counts events per user in an in-memory dict while handling requests on multiple threads. What can go wrong, how do you make it safe, and what changes when it has to scale across processes or machines?

EasyTechnical
25 practiced

What is the difference between concurrency and parallelism? Give examples in Python, Go and Java of code that is concurrent but not parallel and code that is truly parallel, and say what that means for CPU-bound versus I/O-bound work.

That is every published Language-Level Concurrency and Multithreading question for AI Engineer so far. Browse the other topics in this category, or practice this one interactively.