Everything is complete(well it seems so). But, I was wondering what if in the same file which is being read and written to by many users is being accessed but two users to write into. Will it conflict. See for editing any message a this is what I am doing.
1) creating a temp file
2) copying the contents of original file and also the changed message
3) deleting the original file
4) renaming the temp file to original file.
Now here is my doubt. What if at the very instant at which I delete the original file another user asks for it before renaming?? What if two users read the same file and then edited messages and put renamed their respective temp files? Should I take into consideration all these problems? If so how can I solve them. Please specify an algo similar to the one mentioned above.
Regards