Thing is I'm not to sure on how to "use them right" (in quotes because I'm sure there are many situationally beneficial ways to use threads)
I just got past a mild deadlock problem and realized the way I was using threads was causing frequent creation and destruction of threads.
Just for clarification here's a snip of the code:
void Update()
{
IndigoProgram::Update(); //base method
//TODO: Add update logic / Ready Update A, B & C resources
Update_A_Thread = boost::thread(&Program::Update_A, this); //start A
Update_B_Thread = boost::thread(&Program::Update_B, this); //start B
Update_C_Thread = boost::thread(&Program::Update_C, this); //start C
Mutex_A.lock(); //don't continue until A is finished
Mutex_B.lock(); //don't continue until B is finished
Mutex_C.lock(); //don't continue until C is finished
//TODO: Finish with Update A, B & C resources
Mutex_A.unlock(); //free A for next loop
Mutex_B.unlock(); //free B for next loop
Mutex_C.unlock(); //free C for next loop
};
will this constant creation and destruction of threads cause too much overhead?
and I've also noticed, should B for any reason overtake A before A has a chance to lock its mutex there could be deadlocks,
how would I run something along the lines of
while (Mutex_A is unlocked) { }
More so would it be necessary or would A always lock before B starts? (A's first line is locking Mutex_A)Thank you for any and all information,
Bombshell