C++:: Windows Threading Example

Objectives :

  • This example describes to use windows thread function and operations.
  • Note: To resolve the location of windows.h  in Visual Studio Express 2010, windows.h header files was not in place.
    I heard that express edition does not have windows.h ?? -- to be resolved

  •  
 

Step: 1 Create a source file in NetBeans (7.1) or Eclipse. The library <stdio.h> in Quincy compiler (aged and old version 2005) projected some error as shown at the bottom of this document.
Start Eclipse application and  Select a workspace :

This space was empty to begin with, and we are going to add a project.

Create a project, as shown below.

Pick a name of the project, and follow the screen shots.

Create a source file

The wizard creates a source file as you named before.

Step: 2 Edit and save Source file. This example I picked up from a text book, around 2004,  and modified to run bare minimum thread operations. The code runs good in XP-Pro/Eclipse and NetBeans .71 environment. I used a 4 second sleep over so to capture a screen shots.

The same code in NetBean 7.1

Step: 3 Runtime Views:

a ) Testing with Eclipse

Pre-run screenshot: Project is not yet built.

Now Build the Eclipse project

Now Project, is built, meaning all the dependencies and modules are synchronized for runtime oberation.

Running application

At the end of the sleep over.

 

b) NetBeans 7.1 , and ready to launch

Threads created and observed sleep time

At the end thread terminated

 

Step: Error in Quincy

MingW 5.0.3

Well, mingw was a step down, comparing with Eclipse