top | item 15158667

(no title)

fnj | 8 years ago

Honest question: If you aren't going to share data between/among threads, why use threads at all? Why not just fork-abd-exec?

discuss

order

thristian|8 years ago

Sharing (immutable) data between threads is fine, you just don't want to share (mutable) state or else you run the risk of threads stomping on each other. The ideal scenario is map/reduce: you take some large chunk of data, divide it up into smaller chunks, spin up a thread to process each smaller chunk and produce a result. Once the threads have all completed and the results are no longer changing, the main thread can pick them up and combine them to a single result.

It's possible to do that with fork-and-exec, but without a shared address space, marshalling costs make it expensive.

to3m|8 years ago

If it's the same, it's the same, so there's no reason to do one rather than the other. Why not just create a thread?

danieltillett|8 years ago

Because on windows it is much slower.