How does erlang access shared resource?
I am a new to erlang, and erlang is concurrency-oriented programming, it has no mutable data structures, that's why it's easy to parallelize.
But anyway, shared resource is still existed, for example, writing to same file. i开发者_如何学JAVAn this case, how does erlang synchronize accessing the shared resource between two processes?
Typically what you might do is have one process responsible for access to the shared resource. Other processes would send messages to the single manager process for requests to read or write information to the shared resource.
Some shared resources (eg. some types of ETS tables) can be read by multiple processes but only one process can write to it. So you could set up one process to serialise writes to the table but let anybody read from it.
精彩评论