Please advice!
CodePudding user response:
If there are only two threads, a thread only, another thread read-only, the two threads are not necessary to lock,CodePudding user response:
Multithreading, as long as at least one thread in writing, all want to lock in principle,What circumstances do not need to lock? Basic data types, speaking, reading and writing, and don't need to think about data consistency,
CodePudding user response:
Without A lock, B, A lock is useless, multithreading, speaking, reading and writing A non atomic variables, can be read at the same time, can't write at the same time, can't read and write at the same time,CodePudding user response:
Need, or read data is not accurate,A structure, for example, write only modify an element (members), read by this time, the whole structure,
Data is chaotic,
CodePudding user response:
Of course want to lock, multi-threaded file to read and write without lock could be chaosCodePudding user response: