Answer the question
In order to leave comments, you need to log in
Question about synchronization?
I'm using pthread to create a thread in a wrapper class with a bool mAnyField field. In the main function of thread “A”, I check the state of this field a very large number of times and if the field is false, I complete the execution. Actually the question is whether it is possible to change this field from another stream "B" without synchronization and, accordingly, read the field (in stream "A") also without synchronization? What is it for? I don't want to use synchronization just for performance reasons.
Answer the question
In order to leave comments, you need to log in
If only one thread changes the field, and all the others only read, then yes (only do not forget volatile for the field).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question