In a low level language (C, C++ or whatever): I have the choice in between either having a bunch of mutexes (like what pthread gives me or whatever the...
I have the following class. class Test{ public HashSet<string> Data = new HashSet<string>(); } I need to change the field “Data” from different threads, so I would like some...
POSIX allows mutexes to be recursive. That means the same thread can lock the same mutex twice and won’t deadlock. Of course it also needs to unlock it twice,...
I guess the real question is: If I don’t care about dirty reads, will adding the with (NOLOCK) hint to a SELECT statement affect the performance of: the current...
Seeing various locking related question and (almost) always finding the ‘loop because of spurious wakeups’ terms1 I wonder, has anyone experienced such kind of a wakeup (assuming a decent...
If I have 2 synchronized methods in the same class, but each accessing different variables, can 2 threads access those 2 methods at the same time? Does the lock...
C++17 introduced a new lock class called std::scoped_lock. Judging from the documentation it looks similar to the already existing std::lock_guard class. What’s the difference and when should I use...
Can any one tell me the advantage of synchronized method over synchronized block with an example? 23 Answers 23
The MSDN documentation says that public class SomeObject { public void SomeOperation() { lock(this) { //Access instance variables } } } is “a problem if the instance can be...
I’ve heard these words related to concurrent programming, but what’s the difference between lock, mutex and semaphore? 10 s 10 A lock allows only one thread to enter the...