المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Crash in multiple threading with shared resource



C++ Programming
07-15-2011, 03:40 AM
several sockets (multiple threading) on server-side share same public resource, such as user-array, for deleting, adding users etc.

sometimes, server crashes.

reason of server's crashing can't be debugged properly, but, from debug hints, I guess the reason is that when a socket is doing something on user-array but another socket start adding or deleting users on same array.

If this is real reason, how to avoid it? lock user-array? or other ways?

Thanks for comments.