Environment: C++,VS 2008, MFC, app for Windows XP. I have to access & modify a tree structure in 2 threads. My idea is to protect each node with an CCriticalSection that would lo开发者_C百科ck each and every time the node inner data (not child) gets accessed. I am expecting large number of nodes (2-300000).
Can the very large number of critical sections be a problem?
I heard that Windows has an issue with large numbers of open handles, that is why I am asking this.
Unlike mutexes, Critical sections are not kernel objects and only require an OS handle as soon as there is actual attempt by two threads to lock it. read this Matt Pietrek article if you want to know how it works.
精彩评论