how to create Multiple threads ??? problem ???

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2009
Posts: 8
Reputation: defender_ is an unknown quantity at this point 
Solved Threads: 0
defender_ defender_ is offline Offline
Newbie Poster

how to create Multiple threads ??? problem ???

 
0
  #1
Jun 5th, 2009
i am writing a program with threads. it's a simple program in which user will enter how many number of thread he want to be created.
what technique we use to create multiple threads ??

using for loop ???
suppose to run 3 threads...
  1. for(c=0; c<3; c++ ){
  2. pthread_create(&thread[c], NULL, thread_func, NULL);
  3. }
if i use the above case how can i use my thread join statement to wait for all 3 threads???

  1. if (pthread_join(threada[0], NULL) != 0)
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 8
Reputation: defender_ is an unknown quantity at this point 
Solved Threads: 0
defender_ defender_ is offline Offline
Newbie Poster

Re: how to create Multiple threads ??? problem ???

 
0
  #2
Jun 5th, 2009
is my question described very poorly ???
OR
people on this site never have an answer for me ????
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,612
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 463
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: how to create Multiple threads ??? problem ???

 
0
  #3
Jun 5th, 2009
Wait for (join) all the threads.
  1. for (i=0;i<3;i++)
  2. pthread_join(thread[i], NULL);
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC