Suppose I have two threads (threadA and threadB), where threadA is reading from a file et threadB is writing to this same file, here are the two methods :
// Thread A reads
java.nio.file.Files.readAllBytes(Path.get("test.txt"));
// Thread B writes
java.nio.file.Files.write(Paths.get("test.txt"), bytes);
What will happen if both threads run at the same time ?
If threadA begins to read, then threadB writes to the file (threadA hasn't finished yet to read), Will threadA read the original file (before the modification of threadB) or the modified file or will it throw an exception ?