Race condition xảy ra khi nhiều thread truy cập shared data đồng thời và tạo ra kết quả không thể đoán trước.
- Ngăn chặn bằng các synchronization primitives: câu lệnh
lock,Interlockedoperations, hoặc immutable data structures. - Dùng
volatilecho single fields cần visibility. - Ưu tiên thiết kế immutable thay vì synchronization phức tạp.