Tip:
Highlight text to annotate it
X
Hi, I'm Yanitsa, your .Net girl.
Today we are going to talk about thread synchronization. Sometimes you have variables or resources
that multiple threads need to access, but if one thread writes to a variable or resource
at the same time another thread is reading or writing to the same variable or resource,
you could run into collisions. Collisions can result in exceptions, data corruption,
or simply nasty bugs in your code. Let's say you had an example like this. The counter
variable is updated by Thread A, but also displayed to the user by Thread B. So going
back to our example with the trucks, if each truck was a thread and the number of lanes
available allowed the trucks to drive at the same time, but "Oh no", there is a one lane
bridge ahead like this this, what's a girl to do??? Well, there are ways in .NET to avoid
collisions. Next week we will discuss several of these options.
Hope you learned something today from your .Net girl. Bye, bye!