Back to problems

Multithreaded BankAccount Race-Condition Bug Hunt

AI Coding · xAI · Medium

Requirements Consider the following BankAccount implementation and driver, which starts two deposits concurrently: Your tasks are: Find all concurrency defects in this code. Implement a thread-safe alternative. Leave the existing BankAccount unchanged. The interviewer expects a wrapper or subclass that introduces locking; duplicating the class and modifying the copied body is not acceptable. Be prepared to explain how you would approach the same design in Go, where…

Checking your access…