Đang mở hậu trường...
Chọn đáp án để xem tỉ lệ cộng đồng và giải thích. Câu hỏi được chọn tự động — mọi người cùng làm 1 câu mỗi ngày.
Two threads in a banking app each need to lock both `accountA` and `accountB` to transfer money. Thread 1 does `lock(accountA); lock(accountB);` while Thread 2 does `lock(accountB); lock(accountA);`. Occasionally the program freezes with both threads stuck and no CPU usage. What is happening, and what is the simplest fix?