Limited Time Offer:Up to 20% off Hello Interview Premium
Up to 20% off Hello Interview Premium ๐ŸŽ‰
Hello Interview
Learn Low Level Design
Introduction
Delivery Framework
Design Principles
OOP Concepts
Design Patterns
Introduction
Correctness
Coordination
Scarcity
Connect Four
Amazon Locker
Elevator
Parking Lot
File System
Movie Ticket Booking
Logging Service
Rate Limiter
Inventory Management
Vote For New Content
Pricing
Sign in / Sign up
Search
โŒ˜K
Pricing

Tutor

Concurrency

Correctness

Learn how to ensure multiple operations succeed or fail together.


๐Ÿ”’ Correctness is about preventing data corruption when multiple threads access shared state. Two threads both book the same seat. A counter that should be 1000 reads 847. A bank balance missing deposits. The danger isn't deadlock or performance, it's silently producing wrong results.

The Problem

You're building a ticket booking system for a concert venue. Users can browse available seats and book them. Simple enough. But what happens when two users try to book the same seat at the same time?
Alice wants seat 7A. Bob also wants seat 7A. Here's what should happen:
Booking Correct
Alice gets the seat, Bob gets an error. But here's what can happen in a concurrent environment:
Booking Broken
Both users checked availability before either completed their booking. Both saw the seat as available. Both proceeded to book it. Bob's write overwrote Alice's, and now Alice thinks she has a ticket but will show up to find Bob in her seat.
This is a correctness problem. Can multiple threads corrupt shared state? Yesโ€”the check ("is the seat available?") and the action ("book it") happened as two separate steps. Another thread snuck in between them and invalidated the assumption. Alice checked, the answer was yes, but by the time she acted on that answer it was no longer true.
The same pattern appears throughout low-level design interviews. Rate limiters checking if under the limit before allowing a request. Connection pools checking if a connection is free before handing it out. Caches checking if there's room before adding an item. Whenever the validity of a check can change before you act on it, you have a correctness problem.
This article walks through four solutions to correctness problems, from simplest to most complex:
  • Coarse-grained locking protects all related state with one lock
  • Fine-grained locking allows concurrent access to independent resources while protecting related ones
  • Atomic variables work for single variables but fail for multi-field invariants
  • Thread confinement eliminates concurrency entirely for related data
Then we cover the two patterns where correctness bugs appear most often in interviews and how to apply the solutions to them.
  • Check-then-act like booking a seat if available
  • Read-modify-write like incrementing a counter

The Solutions

Every correctness problem can be solved with one of four approaches. We'll walk through them in order of frequency with which they appear in interviews.

Coarse-Grained Locking

Challenges

Read-Write Locks

Fine-Grained Locking

Challenges

Atomic Variables

Challenges

Thread Confinement (Shared Nothing)

Common Bugs

Check-Then-Act

Examples

Read-Modify-Write

Examples

Conclusion

Purchase Premium to Keep Reading

Unlock this article and so much more with Hello Interview Premium
Buy Premium

Currently up to 20% off

Hello Interview Premium

Guided Practice
Exclusive content
Recent interview questions
Learn More
Reading Progress

On This Page

The Problem

The Solutions

Coarse-Grained Locking

Fine-Grained Locking

Atomic Variables

Thread Confinement (Shared Nothing)

Common Bugs

Check-Then-Act

Read-Modify-Write

Conclusion

Questions
Meta SWE Interview QuestionsAmazon SWE Interview QuestionsGoogle SWE Interview QuestionsOpenAI SWE Interview QuestionsEngineering Manager (EM) Interview Questions
Learn
Learn System DesignLearn DSALearn BehavioralLearn ML System DesignLearn Low Level DesignGuided Practice
Links
FAQPricingGift PremiumHello Interview Premium
Legal
Terms and ConditionsPrivacy PolicySecurity
Contact
About UsProduct Support

7511 Greenwood Ave North Unit #4238 Seattle WA 98103


ยฉ 2026 Optick Labs Inc. All rights reserved.