Ask Your Question

Revision history [back]

Issues with multi-threaded programs are usually caused by parallel accesses to shared data structures. Especially STL containers will die in a horrible way if two threads modify them simultaneously, or if a thread accesses them while another thread is writing to them.

Your code looks fine to me (provided the threads array is large enough to hold all handles) and is probably not the source if your problem. Off the top of my head, I'd suggest you take a look at thread_align_cloud_init and verify that anything that is not a local variable is either protected by a mutex or never accessed by two different threads. If other functions are called, the same rule applies to them as well.

Issues with multi-threaded programs are usually caused by parallel accesses to shared data structures. Especially STL containers will die in a horrible way if two threads modify them simultaneously, or if a thread accesses them while another thread is writing to them.

Your code looks fine to me (provided the threads array is large enough to hold all handles) and is probably not the source if of your problem. Off the top of my head, I'd suggest you take a look at thread_align_cloud_init and verify that anything that is not a local variable is either protected by a mutex or never accessed by two different threads. If other functions are called, the same rule applies to them as well.