O'Reilly logo

Microsoft® .NET Compact Framework (Core Reference) by Mark Sutton, Rory MacLoed, Robert Burbidge, Stephen Wheelwright, Andy Wigley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required