Synchronizing Threads and Thread Safety
In the output of the CreatingThreads.cs example, two threads write to the screen using Console.WriteLine. At no point does the output from the two threads get mixed up on the screen. This is because the Console.WriteLine method is thread safe: you can safely call it from more than one thread in a process and know that the critical part in the method where the method actually performs the write operation cannot be entered by more than one thread at a time. If it could, the output of the two threads could be mixed up on the screen.
Thread safety is a very important issue in multithreaded development, and the causes of thread safety problems are often very subtle. Thread safety problems aren’t always easy to ...
Get Microsoft® .NET Compact Framework (Core Reference) now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.