What is the difference between message-passing and method-invocation?

后端 未结 5 1009
盖世英雄少女心
盖世英雄少女心 2021-02-02 07:51

Is there a difference between message-passing and method-invocation, or can they be considered equivalent? This is probably specific to the language; many languages don\'t suppo

5条回答
  •  感动是毒
    2021-02-02 08:37

    They really aren't the same thing in practice. Message passing is a way to transfer data and instructions between two or more parallel processes. Method invocation is a way to call a subroutine. Erlang's concurrency is built on the former concept with its Concurrent Oriented Programing.

    Message passing most likely involves a form of method invocation, but method invocation doesn't necessarily involve message passing. If it did it would be message passing. Message passing is one form of performing synchronization between to parallel processes. Method invocation generally means synchronous activities. The caller waits for the method to finish before it can continue. Message passing is a form of a coroutine. Method-invocation is a form of subroutine.

    All subroutines are coroutines, but all coroutines are not subroutines.

提交回复
热议问题