I need to create a c++ program that creates a number, a, of threads and then for each thread, n (0<n<a)
, asks each thread to sum numbers from 0 to n. So, for example, if the a=5, I need to create 5 threads and the third thread will need to add from 0 to 3. I use the main function and a while loop to dynamically create threads (using pthread_create, I have to use pthreads). Then I have one generic function that all the threads run. My problem is I don't know how to let each thread know which number is it. So, how would the third thread know that it is the third and not the first.
I'm sure this is simple, but I haven't been able to find the answer.
Thanks for your help!
etk1220