Important:
- What happens when they write
- What happens if (a) reads, (b) reads then (b) writes then (a) writes? Is (a) wrong because the calculation is no longer inferred from the last state?
A classic example is the Cash machine / bank balance example used in many texts.
For any type of record sharing , some form of concurrent access control , such as mutex , is required, but there are many potential problems, such as race conditions , starvation, and variations on the philosopher canteen problem .
However, many operating systems allow file locking , which means that another process is waiting for the lock to be released. See PHP flock () for file locking.
You can also use the "checkout, change, commit / merge" approach.
Depending on your reasons, you might want to consider a database such as MySQL or SQLite , as they will provide faster, more reliable ways to share state with read-strength or without cache.
The many challenges, pitfalls and ways to share the state are enormous. Sorry for using Wikipedia.
Aiden bell
source share