Here’s a quick brainteaser for you. Suppose you really want to find all the prime numbers in a certain range, and store them in a List. And also suppose that you want to parallelize that calculation to make it as quick as possible. You then need to synchronize access to the list so that it’s not corrupted by add operations performed in multiple threads. Would it be better to use a C# lock (CLR Monitor) or a Windows mutex to protect the list of primes?
.net
frameworks
other languages