Sign in to follow this  
Asuralm

Multithread in C++

Recommended Posts

Hi all: I have a function
void FuncA(obj o, arg1 a1, arg2 a2);
Because I have to run the FuncA for many times for different objects, I am thinking it's probably better to run multithread so that each thread contains each object. I have just read a small tutorial in http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html However, I am still not sure how to start a thread if the arguments of FuncA is multiple. Also, the pthread_t looks quite out-of-date and it's in C although it works in C++. Could anyone give me any idea how to do this please? Thanks

Share this post


Link to post
Share on other sites
I've recently written a library which does exactly that. It requires boost to run, but other than that it's just a header you include.

Flow

Just make sure that threads don't alter the same objects without locks, and all will be fine.

Share this post


Link to post
Share on other sites

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