Code Example on Synchronization for Multi-threading in a Win32 Environment

by Soumya Gupta, Technical Marketing Engineer
Software Solutions Group, Intel Corporation


Synchronization is essential in programming for multi-threaded applications because concurrent access to shared data may result in data inconsistency since threads normally run asynchronously. The program PrintNumbers.c, which you can download below, is a program that creates multiple threads and displays the thread Ids. The example illustrates that the results of the program running multiple threads can be very unpredictable. Because of this, programmers must examine ways to synchronize threads. For a detailed discussion of how to provide thread synchronization to ensure that you get the results you expect from a program see Multithreaded Programming in a Microsoft Win32 Environment.

Target Audience

Web developers, developers building application server code, developers working with multiple processor systems. Basically any developers working in a 32-bit Windows environment where optimization of code would be of interest via multi-threaded programming would find this example program worth a look.

Sample Category

Full Project

Implementation Language


Target Hardware & Software Platforms

Hardware Systems:
Systems running Intel® Xeon® processors

Operating Systems:
Microsoft Windows* 2000 and other Win32 operating systems


Download Code Sample


Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.