Concurrency: Processes vs Threads

What are the main advantages of using a model for concurrency based on processes over one based on threads and in what contexts is the latter appropriate?


Fault-tolerance and scalability is the main advantages of using processes vs. threads.

A system that relies on shared memory or some other kind of technology only available when using threads, will be useless you want to run the system on multiple machines. Sooner or later you need to communicate between different processes.

Using processes you are forced to deal with communication through messages, which is the Erlang way of doing communication. Data is not shared, so there is no risk of data corruption.

Another advantage of processes is that they can crash and you are perfectly ok with that, because you just restart them (even across network hosts). If thread crashes, it may crash the entire process, which may bring down your entire application. If an Erlang process crashes, you will only lose that phone call, or that webrequest, etc.

OS processes have many drawbacks that make them harder to use, like the fact that it takes forever to spawn a new process. However, Erlang has it's own notion of processes, which are extremely lightweight.

With that said, this discussion is really the topic of research. Please read Joe Armstrongs paper on fault-tolerant systems if you want to know more about Erlang and this kind of philosophy.

Need Your Help

Document Oriented DB for AIR?

database air embedded-database key-value-store document-oriented-db

Today I just learned that Adobe Air has a local SQL database, which is great; however, we had been creating XML and JSON files to handle mostly everything. Rather than re-architect our application to

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.