Reputation: 119
I have a .txt file in a server which will be used for writing enormous data and then reading the data each time the user login in the system .
my question is this:
The total number of users which will be using the system is around 5000 on their suitable time. I am just worried about closing ,opening , reading and writing to the same file and for multiple users on the same time. can you advice if it is safe and it will work.
Upvotes: 0
Views: 409
Reputation: 116
The problem you are worried about is called a race condition. Concurrency control is what controls concurrent access to a resource.
The easiest way to avoid race conditions is to use mutex locks. This way only one person at a time can access it. Note that you cannot write your own lock systems since it still has a race condition. A mutex must be part of the language. The problem with a lock is that the other person has to wait for access.
The best way is to just use a database as suggested and let that handle the concurrency.
Upvotes: 1