What’s dead lock? What will cause dead lock and ho

 A deadlock is a situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does.
 A program probably causes deadlock between two threads that are both trying to acquire locks for the same two resources.
 To avoid this sort of deadlock when locking multiple resources, all threads should always acquire their locks in the same order.
Thread 1 locked resource1, and won't release it 'till it gets a lock on
resource2. This thread2 holds the lock on resource2, and won't
release it 'till it gets resource1. We're at an impasse. Neither thread can run, and the program freezes up.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章