About lock
-
I have a problem about lock in C#. I have written a multithread program, but the other day, the program hung up suddenly. I have checked the code throughly but i could find nothing wrong. In order to realize sync., i use lock(this) at several places. But to my dismay, i was told this is not a good way at all recently. Can anyone give me some information about this? Thank you -- modified at 6:57 Friday 24th March, 2006
-
I have a problem about lock in C#. I have written a multithread program, but the other day, the program hung up suddenly. I have checked the code throughly but i could find nothing wrong. In order to realize sync., i use lock(this) at several places. But to my dismay, i was told this is not a good way at all recently. Can anyone give me some information about this? Thank you -- modified at 6:57 Friday 24th March, 2006
Who told you that it wasn't a good way, and what was the arguments for that? Locking should of course be kept as a minimum, and to avoid deadlocks a thread should never lock more than one object at a time. Still, for sharing data between threads there is hardly any alternative. --- b { font-weight: normal; }