If in our program we are using Threads to access lets say shared collection, then we should ensure thread safety with Mutex, Monitor or Sempahore, et.c
but If we are not using Threads but we are using Tasks and then multiple tasks are trying to access common shared collection then also we should ensure safety by some methods
But If we use some readymade threadsafe collection like ConcurrentDictionary then ensuring locking and thread-task safety is not required as it is already handled at framework level.
So basically i want to know which approach can be used if we are working with shared resource in concurrent consumer environment.
They’re all great solutions for different problems. If you can tell us precisely what you’re trying to do, what resources are shared, what kinds of accesses are required, then we can tell you which is probably right for your solution.