Cadbilbao -
If you're new to C++ and/or C, you might want to wait a bit before diving into multithreaded programming. It's a little complex.
The biggest thing that can bite you is variable access. Say you have two threads, A and B, and a long variable named counter, with an initial value of 4. "A" needs to execute this code:
[tt]counter*=3[/tt]
And "B" needs to execute this code:
[tt]counter+=2[/tt]
The question is: What's the value of counter?
And the answer is: It depends on the order in which the statements were executed.
If thread A executes first, you get 14. If thread B executes first, you get 18. If they execute at the same time (which is possible on a dual-cpu machine), the results are undefined.
So, what you need to make sure is that you try not to access any global variables from within a thread. It's best to lump anything the thread needs into a struct and pass it to the thread routine.
Chip H.