c++.windows.32-bits - win32 working!
- Anuj Goyal (44/44) Jun 30 2004 got win32-pthreads working for dmc. sent changes to the win32-pthread
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