Calculating Primes using Multi-threading in a Win32 Environment

Submit New Article

January 14, 2009 2:36 PM PST



Abstract/Overview

This sample contains a full project that shows how to create multiple threads and use Mutexes. The program creates multiple threads to calculate the prime numbers for any given range. The purpose of this program is not to efficiently calculate primes, but to show how to use mutexes; wait for a thread to complete, and how to release mutexes. The program creates 2 threads and calculates the prime numbers. The main function takes the upper bound as an argument to compute primes within the upper bound range and displays all the prime numbers found.


Target Audience:

Web developers, developers building application server code, and developers working with multiple processor systems. 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:

Nonspecific


Target Hardware & Software Platforms

Hardware Systems: Systems running Intel® Xeon® processors
Operating Systems: Microsoft Windows* 2000 and other Win32 operating systems
Compilers: nonspecific


About the Author
Soumya Gupta is a Technical Marketing Engineer in the Software Solutions Group at Intel Corporation.