Recall & Review
beginner
What does thread safety mean in system design?
Thread safety means that a piece of code or design works correctly when multiple threads access it at the same time without causing errors or unexpected behavior.
Click to reveal answer
beginner
Name one common problem caused by lack of thread safety.
Race conditions, where two or more threads try to change shared data at the same time, causing wrong or unpredictable results.
Click to reveal answer
intermediate
What is a mutex and how does it help with thread safety?
A mutex is a lock that allows only one thread to access a resource at a time, preventing conflicts and ensuring thread safety.
Click to reveal answer
intermediate
Explain immutable objects and their role in thread safety.
Immutable objects cannot be changed after creation, so multiple threads can read them safely without locks, making design simpler and safer.
Click to reveal answer
advanced
What is the difference between concurrent and parallel execution in thread safety context?
Concurrent means multiple threads make progress by switching time slices, while parallel means threads run at the same time on different processors. Both need thread safety to avoid conflicts.
Click to reveal answer
Which of the following best describes a race condition?
✗ Incorrect
Race condition happens when multiple threads access shared data simultaneously without synchronization, causing errors.
What does a mutex do in thread-safe design?
✗ Incorrect
A mutex locks a resource so only one thread can access it at a time, ensuring thread safety.
Why are immutable objects considered thread-safe?
✗ Incorrect
Immutable objects do not change, so multiple threads can read them safely without synchronization.
Which technique is NOT typically used to achieve thread safety?
✗ Incorrect
Ignoring shared data access can cause race conditions and is not a thread safety technique.
What is the main goal of thread-safe design?
✗ Incorrect
Thread-safe design ensures correct behavior when multiple threads access shared resources.
Describe what thread safety means and why it is important in system design.
Think about what happens when many people try to use the same tool at once.
You got /3 concepts.
List and explain at least three techniques to achieve thread safety in a design.
Consider how to control access or avoid conflicts.
You got /4 concepts.