Concurrency, Synchronization & Deadlock Questions
Coordinating concurrent execution against shared state: mutexes, semaphores, condition variables, spinlocks, and atomic operations, plus the problems they solve and cause. Covers race conditions, critical sections, the classic deadlock conditions and prevention/avoidance strategies, priority inversion, and livelock at the OS level.
Explain Kotlin coroutines basics for Android: CoroutineScope, Dispatchers (Main, IO, Default), launch vs async, structured concurrency, and how coroutine contexts control thread dispatching. Mention common pitfalls when switching dispatchers.
You have an image-processing pipeline: fetch image -> decode -> run ML detection -> annotate -> render. Design how to schedule these stages across threads to maximize throughput and minimize UI latency on mobile devices with limited cores and battery. Discuss pooling, batch sizes, backpressure, prioritization of visible images, and memory constraints.
Design a background synchronization system for a mobile app that keeps a local database in sync with a remote server. Requirements: tolerate intermittent connectivity, conserve battery and network, handle conflict resolution, retry with backoff, and scale to many records. Describe architecture, thread model, scheduling (iOS BGTaskScheduler and Android WorkManager/JobScheduler), conflict strategy, and data-flow for sync operations.
Design a thread-safe caching layer on Android using Kotlin coroutines and Flow that exposes a Flow of cached values, supports refresh on demand, avoids blocking the main thread, and safely invalidates stale entries. Describe APIs, coroutine scopes, dispatcher choices, and how you handle concurrent refreshes for the same key.
Explain practical steps you would take to reproduce, isolate, and fix a concurrency bug that only appears under heavy load on real devices. Include instrumentation, logging, deterministic reproductions, and mitigation strategies for production.
Unlock Full Question Bank
Get access to all 35 Concurrency, Synchronization & Deadlock interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.