What's the difference between “green threads” and Erlang's processes?

后端 未结 3 1505
礼貌的吻别
礼貌的吻别 2020-12-31 11:43

After reading about Erlang\'s lighweight processes I was pretty much sure that they were \"green threads\". Until I read that there are differences between green threads and

3条回答
  •  醉话见心
    2020-12-31 12:11

    When people object to calling Erlang's processes "green threads", they aren't objecting to the "green" part, they are objecting to the "threads" part.

    The difference between threads and processes is basically, that threads have only their own instruction pointer, but share everything else (especially state, memory, address space). Processes OTOH are completely isolated and share nothing.

    Erlang's processes share nothing, thus, they are true processes. However, they are usually implemented in a "green" manner. So, technically, they are "green processes".

    I usually call them "green threads" when I want to emphasize the light weight implementation, and call them "processes" when I want to emphasize the shared-nothing semantics. That way I don't have to explain what I mean by "green processes".

提交回复
热议问题