I am writing a script using two separate streams, one of which performs a file reading operation, and the other one adds, both of which work quite often.
My question is, if one thread is reading a file and the other is in the middle of additional lines, such as “This is a test” in this file, what will happen?
I know if you add a line smaller than the buffer , no matter how often you read the file in other streams, there will never be such an incomplete line as “This i” appearing in your read file, I mean, what os will either do: add "This is a test" → read information from a file; or: read information from a file → add “This is a test” to the file; and this will never happen: add "This i" → read information from the file → append "s test".
But if "This is a test" is large enough (assuming it is a string larger than the buffer) ), os cannot add the task to one operation, so divide the add task by two: first add "This i" to the file, then add "sa test", so in this situation, if I happen to read the file in the middle of the whole upload operation, will I get the following result: append "This i" → read information from the file → add "sa test", which means that I can read a file containing an incomplete line?
Shane source share