Original Post
I am writing a game server using mutiple threads, and there is quite a bit of shared data between the threads. Do I need to put something in a mutex if it is only reading? I know you need to put it in a mutex if it writes, but I keep going back and forth if you need to or not for reading. Example, do I need to do this: for (int i = 0; i < p->nNumEnemies; i++) { //do whatever } or WaitForSingleObject(p->hEnemiesMutex,INFINITE); int CopiedVariable = p->nNumEnemies; ReleseMutex(p->hEnemiesMutex); for (int i = 0; i < CopiedVariable; i++) { //do whatever } If the second of the two is neccessary, then I have a lot of work to do, there are many instances of that. Thank you Dev578