I have a problem where I have a datastructure and multiple threads trying to do operations on it. To say it as simple as possible: I have thread A, B and C. Thread A can only do its operation, as long as B and C are not making any changes to the data set. B and C can operate simultaneously on the set most of the time though. So the goal is:
- Thread A blocks B & C
- Thread B & C block A
- Thread B does NOT block C (and vice versa)
The question is, how can I achieve that? I hope it is clear what I am trying to do. If not, feel free to comment. I have deliberately not provided any code, as it is in my opinion easier to grasp the problem this way (a lot of long code).