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 ++?

  1. Download pthreads devpak
  2. Install it in Dev C ++
  3. Create new project in Dev C ++
  4. Then go to Project Menu -> Project Options -> Select "Parameter Tab"
  5. Select the "Add Library or Object" option
  6. Select the "libpthreadGC2.a" file from the Dev C ++ installation directory in the LIB directory.
  7. OK
  8. Li>
  9. 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

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -