You may also want to research how to lock the file from read through write. If multiple processes have the opportunity of simultaneous execution, you have a race condition where you can get anything from the correct behavior to missing one of the updates, to corrupting the data in the file.
In this case I don't think you have the possibility of corruption (that scenario can happen more easily on files with larger datasets), but you may miss one of the updates. ProcA starts and reads the counter. ProcB gets control, reads the counter (same value), increments, and writes the counter. ProcA now resumes, increments the (now outdated) counter, and writes it. Your counter is now one less than it should be.
--MidLifeXis
In reply to Re: File reade and recreate
by MidLifeXis
in thread File reade and recreate
by adriang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |