Sign in to follow this  

Multi threading question

This topic is 4726 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

The thread's process will be spawned 5 times, but the handle for the thread ('th1' in this case), is overwritten each time the loop is executed, so you end up with th1 being the 5th thread.

You might want to consider crating an array to store the threads, and shift the index, since you'll be counting anyway. ;)


int numThreads = 5;
<thread type> threads[numThreads];
int i;
for (i = 0;i < numThreads;i++){
threads[i] = <create spawning function>;
}

Share this post


Link to post
Share on other sites

This topic is 4726 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this