Debug a race condition
Identify unsafe shared state under concurrent load and rewrite it with proper synchronization primitives. Explains race condition mechanics for the specific language.
Preview
Copy prompt
This code has an intermittent bug that only surfaces under concurrent load: [Paste code]. Explain what a race condition is in this specific context and point to the exact lines where shared state is accessed unsafely. Rewrite the affected section using appropriate synchronization primitives for [Language] such as mutexes, locks, or atomic operations, and explain why each change prevents the race.
More
Debugging
Prompts
