Of course multithreading comes with a whole host of synchronization problems. There are concurrency problems which lead to indefinite states,  and other complicated 'programming traps' such as race conditions and deadlocks. Hence, it is important for a C# developer using threads to be well versed in thread synchronization.
 For example, if we have two concurrently running threads getting and setting the value of a shared variable, the exact value stored in this variable will be indefinite at any one time.
In this section, I will introduce the lock keyword, and two more classes – Mutex and Monitor.
Table 17.3 gives some initial clues as to how thread synchronization compares in C# and Java.