|
Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++.windows.32-bits - win32 working!
got win32-pthreads working for dmc. sent changes to the win32-pthread
maintainer, should be rolled into next release. believe me folks, using the
pthread API is much eaiser than using the win32 threading API (in my opinion).
/*
* dmc -I.;c:dminclude -WA hello.c pthread.lib
*/
#include "pthread.h"
#include <stdio.h>
#define NUM_THREADS 5
void *sayhello(void *threadid)
{
printf("\n%d: Hello World!\n", threadid);
pthread_exit(NULL);
return;
}
int main(int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc, t;
for(t=0;t<NUM_THREADS;t++){
printf("Creating thread %d\n", t);
rc = pthread_create(&threads[t], NULL, sayhello, (void *)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
//pthread_exit(NULL);
for(t=0;t<NUM_THREADS;t++){
pthread_join(threads[t], NULL);
}
return 0;
}
D:\win32_pthreads\pthreads>hello.exe
Creating thread 0
Creating thread 1
Creating thread 2
Creating thread 3
Creating thread 4
0: Hello World!
1: Hello World!
2: Hello World!
3: Hello World!
4: Hello World!
Jun 30 2004
|