Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 289667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:55:39+00:00 2026-05-12T05:55:39+00:00

I have the following Windows code that spawns two threads then waits until they

  • 0

I have the following Windows code that spawns two threads then waits until they have both completed:

hThreads[0] = _beginthread(&do_a, 0, p_args_a);
hThreads[1] = _beginthread(&do_b, 0, p_args_b);
WaitForMultipleObjects(2, hThreads, TRUE, INFINITE);

I am now porting the same code to use pthreads but am unsure how to do the equivalent of WaitForMultipleObjects:

pthread_create(&hThreads[0], 0, &do_a, p_args_a);
pthread_create(&hThreads[1], 0, &do_b, p_args_b);
???

Is there an equivalent way, using pthreads, to achieve the same functionality?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:55:40+00:00Added an answer on May 12, 2026 at 5:55 am

    If you want to wait for all, as you’re doing here, you can simply call pthread_join() for each thread. It will accomplish the same thing.

    pthread_create(&hThreads[0], 0, &do_a, p_args_a);
    pthread_create(&hThreads[1], 0, &do_b, p_args_b);
    
    pthread_join(hThreads[0], NULL);
    pthread_join(hThreads[1], NULL);
    

    You can get fancy and do this in a for loop if you’ve got more than a couple of threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following windows batch code: for %%i in (iidbms iigcc iigcd dmfacp
I have some existing C code that uses ICMP raw sockets to do Ping
I need to create Solution Architechure for Windows Mobile and have following queries: My
I have written a windows service, which monitors a database table for pending jobs
I have the following http://jsbin.com/ojeja4/2/edit The button and the expiration date working correct in
I recently created a Windows service. One thing that it faithfully does is log
I have the following cell which is used for my custom column data type
I have created a JSP code where we can upload a .csv file. The
I have a namespace extension and when the user does certain action we display
I have an application where I am rendering a SSRS report via the SOAP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.