Golang Concurrency Exercise: Debug and Fix Atomic Transaction Bugs
In this hands-on programming exercise, you'll play the role of a software engineer tasked with fixing a concurrent banking system that's losing money. The program simulates multiple transfers between two bank accounts (Alice and Bob), but there's a problem: money seems to be disappearing from the system!
Your Mission:
- Run the buggy program and observe the incorrect behavior
- Hunt down the concurrency bugs that cause race conditions and inconsistent balances
- Fix the issues using proper synchronization techniques
- Verify that the total money in the system remains constant
What You'll Learn:
- How to identify and fix race conditions in Go
- Proper use of mutexes for protecting shared data
- Techniques for making multi-step operations atomic
- Deadlock prevention in concurrent financial transactions
- Best practices for mutex management with defer statements
Comments