consider the following scenario:
- Process 1 (Writer) continuously appends a line to a file ( sharedFile.txt )
- Process 2 (Reader) continuously reads a line from sharedFile.txt
my questions are:
In java is it possible that :
- Reader process somehow crashes Writer process (i.e. breaks the process of Writer)?
- Reader some how knows when to stop reading the file purely based on the file stats (Reader doesn't know if others are writing to the file)?
to demonsterate
Process one (Writer):
...
while(!done){
String nextLine;//process the line
writeLine(nextLine);
...
}
...
Process Two (Reader):
...
while(hasNextLine()){
String nextLine= readLine();
...
}
...
NOTE:
Writer Process has priority. so nothing must interfere with it.