Hello,
I posted awhile back about multithreading and was directed to boost.org. What I've read has been good, and I've been trying to get it work for awhile now. I'm using VC++2008 Express (9.0) and haven't been able to link (under: Options > Projects and Solutions > VC++ Directories) the header or prebuilt libraries. Does anyone know why? I used the installer found here: http://www.boostpro.com/products/free . Any ideas?
Okay, I tried that earlier... but it took awhile and I didn't get too far. However, I renamed the obj library's to what VC++ thought they were and it works. Now I'm just trying to learn how to make threads, pass functions to them, inturrupt them, and stuff like that. If you have any tips, I'd appreciate them, but boost.org is helping me too. Thanks again,
I found using thread groups to be the best approach;
1 2 3 4 5 6 7
// Create Threads
boost::thread_group threads;
for (int i = 0; i < iNumberOfThreads; ++i)
threads.create_thread(&CRuntimeController::initMCMCThread);
// Wait for Threads to finish.
threads.join_all();
But I still am at a loss as to where I would pass arguments to this function. I did some more reading but would like a second explination if you don't mind, as it's a bit confusing. Let me know what you think.
You're right at the problem I'm having with a single thread (boost::thread mythr).
You declare a thread, but how do you pass a function to it? I've used something similar to this :
thread_group threads
and threads.create_thread(func1) to create a new thread. but it gives me an error if I try to do somthing like this:
1 2
boost::thread mythr;
mythr.create_thread(func1); // error, no create_thread() func for boost::thread
I've tried using something like join() to append my function to the new thread but to no avail. I'm new to multithreading as I am to the boost libraries, so bear with me. Any ideas? Passing a single function to a single thread...