Multithreading using Lock, threads rarely skip over lock
hi,
rarely, thread skips on lock, in should not of course. wondering if using array problem lock object? also, project highly cpu intensive, , wondering if issue why jumps on lock?
// code run once constructor ................ object[] _lock = new object[2]; // issue since using array instead. // ini (int = 0; < _lock.length; i++) _lock[i] = new object(); // code multi-threaded & run multiple times ......... lock (_lock[0]) { // single work } // work lock (_lock[1]) { // single work }
thank you,
andrew
>you want me post 10,000 lines of code??
no, that's why suggested you try to produce simple, self-contained repro , post that.
>please don't there bug in code because didn't how conveyed problem.
that's not meant. there's bug in code because seeing occasional failures (ie lock works), , haven't found bug because code overly complex.
david
david http://blogs.msdn.com/b/dbrowne/
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment