visual studio 2008 - multithreading dispute on local variables -
i had implemented few methods being handled individual background threads. understand complexity of doing things way when tested results seemed fine. each thread accesses same variables @ times , there maximum of 5 threads working @ given time , guess should have used synchlock question whether there can way threads have been executing processes without overwriting variable contents. under impression each thread allocated site in memory variable , though named same, in memory different location mapped specific thread, right? if there collisions should getting error cannot access variable if used thread.
am wrong on this?
- if talking local variables of function - no, each thread has own copy of on stack.
- if talking member variables of class being accessed different threads - yes, need protect them (unless read-only)
Comments
Post a Comment