DevPrep

All topics › Multithreading & concurrency

Livelock

Senior PRO

The essence

A livelock is when threads are not blocked and keep changing state, yet do no useful work: each reacts to the other's action and the system spins in place. Unlike a deadlock, the stacks show no waiting — just endless activity that eats CPU. Unlike starvation, all participants suffer, not a single low-priority thread.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store