vc++6.0 Configuration Pthread Library December 12, 2010 Sunday 13:14VC pthread multi-threaded programming reprint
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
void* Tprocess1 (void* args) {
int i=1;
while (i<=10) {
printf ("process1:%d\n", I);
i++;
}
return NULL;
}
void* Tprocess2 (void* args) {
int i=1;
while (i<=10) {
printf ("process2:%d\n", I);
i++;
}
return NULL;
}
int main () {
pthread_t T1;
pthread_t T2;
Pthread_create (&t1,null,tprocess1,null);
Pthread_create (&t2,null,tprocess2,null);
Pthread_join (T1,null);
Pthread_join (T2,null);
return 0;
}
Some configuration needs to be done before running:
1. Download Pthread's Windows Development Kit Pthreads-w32-2-4-0-release.exe (any one version available)
http://sourceware.org/pthreads-win32/, unzip to a directory.
2. Locate the Include and Lib folders, and add them below to the vc++6.0 header file path and the static link library path, respectively:
a). Tools->options, select the Directory page, and then select Include files (default) in Show directories for:
Add the path to the include in directories. In Show directories for: Select library files,
Add the path to the Lib in the directories.
b). project->settings, select the link page, and then add the *.lib file under Lib to the Object/library Modules,
Each lib file is separated by a space.
c). Copy the *.dll file under Lib to the project directory, which is the root directory.
vc++6.0 Configuration Pthread Library December 12, 2010 Sunday 13:14VC pthread multi-threaded programming reprint