KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I was recently in an interview and the tech guy asked me about how to make an application thread-safe. Well, after explaining the lock() correctly, he said it is not a good idea to have the object as static. private static readonly object _syncLock = new object(); He claimed the reason is that static makes that object slower for threads to lock than if it was non static. Is this true? EDIT: Nonetheless I am still not sure. What is the difference between these three approaches? private static readonly object _syncLock = new object(); public static readonly object _syncLock = new object(); private readonly object _syncLock = new object();
Tags (comma-separated)
Save Edits
Cancel