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

Main menu dropdown parent item clickable in Drupal 8 using Bootstrap 4

 Edit menu--main.html.twig template file {# /**  * @file  * Bootstrap Barrio's override to display a menu.  *  * Available variables:  * - menu_name: The machine name of the menu.  * - items: A nested list of menu items. Each menu item contains:  *   - attributes: HTML attributes for the menu item.  *   - below: The menu item child items.  *   - title: The menu link title.  *   - url: The menu link url, instance of \Drupal\Core\Url  *   - localized_options: Menu link localized options.  *   - is_expanded: TRUE if the link has visible children within the current  *     menu tree.  *   - is_collapsed: TRUE if the link has children within the current menu tree  *     that are not currently visible.  *   - in_active_trail: TRUE if the link is in the active trail.  */ #} {% import _self as menus...

Add JS to the bottom of the page in Drupal 7

How to add JS at bottom of a particular page in Drupal 7 Step 1: Get the page id. In case of front page "is_front"  Step 2: In template.php file of your theme add the below code : function illume_preprocess_page(&$variables) { if ($variables['is_front']) { drupal_add_js(path_to_theme().'/js/util.js', array('type' => 'file', 'scope' => 'footer')); drupal_add_js(path_to_theme().'/js/main.js', array('type' => 'file', 'scope' => 'footer')); drupal_add_js(path_to_theme().'/js/slideimage.js', array('type' => 'file', 'scope' => 'footer')); $variables['bottom_scripts'] = drupal_get_js(); } } This way you can add JS file using drupal_add_js() and define scope as footer. Step 3: Now you can use bottom_script variable to the page tpl file where you want to add JS print $bottom_scripts;

Use Case Diagram for Online Book Store