... continued
Continues the discussion on C#'s memory model.
We'll cover the following...
We'll cover the following...
Let's take another common example quoted in online literature that illustrates the effects of reordering operations. Study the code below:
Say the two threads A and B run the methods threadA() and threadB() respectively. Ignoring the memory model we can conclude that there can be one of two outcomes:
Either nothing gets printed on the console if thread B runs before thread A.
7 is printed on the console.
If we take the memory model into account, we can have any of the following outcomes:
Nothing is printed on console.
7 is printed on the console. ...