↧
Answer by David Schwartz for Is a lock (threading) atomic?
No, it's not really expensive. There are typically only two possibilities:1) The system has other things it can do: In this case, the system is still doing useful work with all available cores.2) The...
View ArticleAnswer by Anna for Is a lock (threading) atomic?
Yes, a context switch can definitely occur.This is exactly why when accessing a shared resource it is important to lock it from another thread as well. When thread A has the lock, thread B cannot...
View ArticleAnswer by dsimcha for Is a lock (threading) atomic?
You're exactly right. That's one reason why it's so important to lock for short period of time. However, this isn't as bad as it sounds because no other thread that's waiting on the lock will get...
View ArticleAnswer by Jon Skeet for Is a lock (threading) atomic?
The processor can very definitely still switch to another thread, yes. Indeed, in most modern computers there can be multiple threads running simultaneously anyway. The locking just makes sure that no...
View ArticleIs a lock (threading) atomic?
This may sound like a stupid question, but if one locks a resource in a multi-threaded app, then the operation that happens on the resource, is that done atomically?I.E.: can the processor be...
View Article
More Pages to Explore .....