Skip to content

Commit

Permalink
c3-m2 race conditions and interleaving explaination
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangbits committed Jun 24, 2020
1 parent 1edb8ce commit 33ecaba
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions c3-m2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,16 @@ func bar(a *int, wg *sync.WaitGroup) {
fmt.Println(*a)
wg.Done()
}

/**
Race Condition
Interleave: If I have 2 task and Order of execution between concurrent tasks
is not known, it's not determined, meaning it's not deterministic
It means these tasks can be interleaved in different ways.
Interleave is happening at the machine code level rather than the source code
Race condition is a problem where the outcome of the program depends on the interleaving
And Interleaving is non-deterministic.
It's determined by the operating system and the Go-runtime.
So, the interleaving can change every time you run it.
**/

0 comments on commit 33ecaba

Please sign in to comment.