如何在Erlang shell中获取当前进程的进程ID?

时间:2016-09-13 22:37:06

标签: erlang erlang-shell

如何在Erlang中访问shell时获取当前正在运行的进程的进程ID

1 个答案:

答案 0 :(得分:7)

<强>过程      - 并发的基本单位      - 产卵便宜      - 拥有自己的堆栈和堆 - 不与其他进程共享内存      - 通过异步消息传递完成通信。      - 示例:

Erlang shell访问

   > self().
     <0.720.0>  -- Process id
   > self() ! {hello, world}, ok.
      ok
   > self() ! {hello, world}, ok.
      ok
   > flush().        // Prints what you had done in the session
     Shell got {hello, world}   
     Shell got {hello, world}
     ok
相关问题