multithreading - Synchronization of threads slows down a multithreaded application -


i have multithreaded application written in c#. noticed implementing thread synchronization lock(this) method slows down application 20%. expected behavior or should implementation closer?

locking add overhead, can't avoided. of threads waiting on resources released, rather grabbing them when feel like. if implemented thread synchronization correctly, thing.

but in general, question can't answered without intimate knowledge application. 20 % slowdown might ok, might locking broadly, , program (in general) slower.

also, please dont use lock(this). if instance passed around , else locks on reference, have deadlock. best practice lock on private object noone else can access.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -