That's a tricky question. There are plenty of ways of dealing with it. Most of them deal with locking the data at some part of the system.
So for example, you can lock the data in the database when the first user looks at it, or you can lock the data at the application thread level when the first user looks at it. However, this causes problems whenever user two wants to update something, but can't because user 1 is in the way. So much for locking.
The second option is to allow for so-called 'dirty reads' this is the situation that you describe. Now the 1st user gets a set of data that was up-to date when he got it, but may change. This is kind of how the TFP works (you can leave a screen showing the latest posts up, but in the background all sorts of things could be happening etc)
The only way to keep no 1 up to date is to keep refreshing his data - perhaps every few minutes etc - or maybe only if he decides to change something.
|