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.
Design and sketch an implementation of a thread-safe memory pool/allocator for small frequently allocated objects used by a performance-sensitive iOS game. Requirements: minimize lock contention with per-thread caches, support dynamic growth and reclamation, avoid fragmentation, and provide fast lock-free paths where possible. Explain chosen data structures, synchronization strategy, and how to handle thread exit and reclamation.
A complex intermittent deadlock involves a background sync thread pool, a SQLite wrapper using a single connection, and UI code that sometimes performs synchronous DB reads on the main thread. Propose a root-cause analysis plan listing which thread dumps and lock-orderings to inspect, and recommend architectural and code changes to eliminate deadlock while preserving responsiveness. Provide an example of safe DB access code that avoids blocking the main thread.
Explain what the main/UI thread is on iOS and Android, why UI operations must run on it, and give two examples of operations that must run on the main thread. In your answer mention platform APIs you would use to schedule UI work and a brief consequence of violating this rule (e.g., UI freeze, ANR).
You observed a priority inversion on iOS where a low-QoS task holds a lock while doing synchronous disk writes, blocking a UI task. Propose code-level fixes (for example moving disk IO out of critical sections, using atomic file writes) and larger architectural changes to eliminate the inversion. Explain how you would test under stress and which Instruments views you would use to validate the fix.
An Android app using ThreadPoolExecutor occasionally throws RejectedExecutionException under heavy load. Which executor parameters and runtime metrics would you inspect, what immediate configuration changes or rejection handlers might you apply, and what long-term architectural changes would you propose to handle bursty incoming tasks without exhausting resources?
Unlock Full Question Bank
Get access to all 35 Language-Level Concurrency and Multithreading interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.