4 ms·
> Basically any process in real life you do that involves collaborating with multiple people is a collaborative multi-threaded process. I would argue that the
by derefr 7y ago
> Basically any process in real life you do that involves collaborating with multiple people is a collaborative multi-threaded process.
I would argue that the code equivalent of people collaborating in the real world is multiple processes with IPC (or even further afield, multiple nodes in a distributed system), not threads. You don’t share memory with other human beings. Imagine how productive you could be if you did!
- harikb 7y agoIf we read other people’s (say a manager, who is giving work) mind and just did that, we would be in the exact mess we are with shares mutable state.
- SeekingMeaning 7y agoImagine reading someone else’s mind, only to discover that they are reading yours... Mind-stack overflow?
- derefr 7y agofor certain classes of problems, sure. But how about “embarrassingly parallel” jobs (e.g. weeding a garden) or even “idempotent OLTP” jobs (e.g. studying several subjects at once)? (Technically these aren’t best expressed as SHM but rather as a tuplespace or greedy worker-pool abstraction, but they can be achieved starting off with “just” an SHM threading primitive, so they count, I think.)
- deleted 7y ago[deleted]
- nybble41 7y ago> You don’t share memory with other human beings. This really depends on where you draw the boundaries. In a computer everything is "memory" of one kind or another, but that doesn't necessarily correspond to human memory. The analogy works if you think of the "actor" as merely the thread's context and dedicated working space (stack), with everything else being part of the surrounding environment. In the real world we don't have anything akin to process separation, except by convention. Even the body itself can be directly manipulated by others. The convention we use for communication between individuals looks more like a message-passing system, but physical manipulation of matter is more like operating on data in shared memory. There is no physical law preventing someone else from coming along and messing with an object I happen to be holding any more than the rules of a computer prevent one thread from messing with a data object held by another thread.