windows vista - How to use pthread library in DevC++? -
I have downloaded the pthread package from what I should do now to use it in Devak ++?
- Download pthreads devpak
- Install it in Dev C ++
- Create new project in Dev C ++
- Then go to Project Menu -> Project Options -> Select "Parameter Tab"
- Select the "Add Library or Object" option
- Select the "libpthreadGC2.a" file from the Dev C ++ installation directory in the LIB directory.
- OK Li>
- Now test the sample code ready to run ..
Sample code:
#include & lt; Iostream & gt; # Include & lt; Pthread.h & gt; using namespace std; Void * fun_thread1 (Zero * data) {for (int i = 0; i <100; i ++) {cout & lt; & Lt; Endl & lt; & Lt; "1 in thread" & lt; & Lt; Endl; }} Void * fun_thread2 (Zero * data) {for (int i = 0; i <100; i ++) {cout & lt; & Lt; Endl & lt; & Lt; "2 in thread" & lt; & Lt; Endl; }} Int main (int argc, char * argv []) {int position; // Creating Thread Objects pthread_t thrd_1; Pthread_t thrd_2; // Create thread pthread_create (& amp; thrd_1, NULL, fun_thread1, (Zero *) 0); Pthread_create (and thrd_2, NULL, Funny _ Thread 2, (Zero *) 0); Pthread_join (thrd_1, (zero **) and position); Pthread_join (thrd_2, (zero **) and position); System ("pause"); Return EXIT_SUCCESS; }
Comments
Post a Comment