Difference between racearound condition and deadlock

前端 未结 5 1924
遇见更好的自我
遇见更好的自我 2020-12-07 10:24

What is the difference between a dead lock and a race around condition in programming terms?

5条回答
  •  悲&欢浪女
    2020-12-07 10:55

    A deadlock is when two (or more) threads are blocking each other. Usually this has something to do with threads trying to acquire shared resources. For example if threads T1 and T2 need to acquire both resources A and B in order to do their work. If T1 acquires resource A, then T2 acquires resource B, T1 could then be waiting for resource B while T2 was waiting for resource A. In this case, both threads will wait indefinitely for the resource held by the other thread. These threads are said to be deadlocked.

    Race conditions occur when two threads interact in a negatve (buggy) way depending on the exact order that their different instructions are executed. If one thread sets a global variable, for example, then a second thread reads and modifies that global variable, and the first thread reads the variable, the first thread may experience a bug because the variable has changed unexpectedly.

提交回复
热议问题