Q1medium
Two threads both execute count = count + 1 at the exact same time. The initial value is 0. After both finish, the value is 1 instead of 2. This is a classic example of:
Topic-wise practice questions for Programming (C++ / Java / Python). Test your knowledge, check solutions on demand, and pace your preparation.
Thread A: Lock(m); x = x + 1; Unlock(m);
Thread B: Lock(m); x = x + 1; Unlock(m);
If x starts at 0, what is the guaranteed result?