Skip to main content

Configure pthread library in DevC++

Step 1: Download pthread library package Download

Step 2: Install pthread devpak
            Way 1: Double click the pthread devpak.
            Way 2: * Open DevC++
                        * Goto Tools in the menu bar and then select Package Manager

                     

                       * Goto Install tab in the menu bar of DevC++ Package Manager and select downloaded                              pthread devpak        


                        * After that Install package
 
Step 3Create new Project in Dev C++ and write your code.


Step 4: After goto Project menu => Project Option => Select Parameter Tab


Step 5: Select Add Library or Object option.


Step 6: Select libpthreaGC2.a file from installtion directory of Dev C++. It will be in lib directory.


Step 7: Press OK.


Step 8: Final step compile and run your program.


Code: -



#include <iostream>
#include <pthread.h>
using namespace std;
void * fun_thread1(void *data)
{
    for(int i=0;i<100;i++)
    { 
        cout<<endl<<"In Thread 1"<<endl;
    }     
}
void * fun_thread2(void *data)
{
    for(int i=0;i<100;i++)
    { 
        cout<<endl<<"In Thread 2"<<endl;
    }     
}
int main(int argc, char *argv[])
{
    int status;
    // creating thread objects
    pthread_t thrd_1;
    pthread_t thrd_2;
    // create thread
    pthread_create(&thrd_1,NULL,fun_thread1,(void *)0);
    pthread_create(&thrd_2,NULL,fun_thread2,(void *)0);    
    pthread_join(thrd_1, (void **)&status);
    pthread_join(thrd_2, (void **)&status);
    system("PAUSE");
    return EXIT_SUCCESS;
}




Comments

  1. I am getting pthreadGC2.dll is missing error. Any help?

    ReplyDelete
    Replies
    1. Download this dll fixer
      http://www.dll-files.com/dllindex/dll-files.shtml?pthreadgc2

      Delete

Post a Comment

Popular posts from this blog

Use Case Diagram for Online Book Store

Linear search & Binary search using Template

Write a program to search an element from a list. Give user the option to perform Linear or Binary search. Use Template functions. #include<iostream> using namespace std; template <class T> void Lsearch(T *a, T item, int n) { int z=0; for(int i=0;i<n;i++) { if(a[i]== item) { z=1; cout<<"\n Item found at position = "<<i+1<<"\n\n"; } else if(z!=1) { z=0; } } if(z==0) cout<<"\n Item not found in the list\n\n"; } template <class T> void Bsearch(T *a, T item, int n) { int beg=0,end=n-1; int mid=beg+end/2; while((a[mid]!=item) && (n>0)) { if(item>a[mid]) beg=mid; else end=mid; mid=(beg+end)/2; n--; } if(a[mid]==item) cout<<"\n Item found at position = "<<mid+1<<"\n\n"; else cout<<"\n Item not found in the list\n\n"; } void main() { int iarr[10] = {2,42,56,86,87,99,323,546,767,886};

Online Movie Ticket Booking Sequence Diagram