无涯教程-Erlang - whereis函数

45 阅读1分钟

它称为whereis(Name)。返回使用该名称注册的进程的pid。

whereis - 语法

whereis(atom,pid)

whereis - 参数

  • atom -这是要赋予该过程的注册名称。

whereis - 返回值

绑定到原子的进程ID。

whereis - 示例

-module(helloLearnfk). 
-export([start/0, call/2]). 

call(Arg1, Arg2) -> io:fwrite("pn",[Arg1]).

start() -> Pid=spawn(?MODULE, call, ["hello", "process"]), register(myprocess, Pid), io:fwrite("pn",[whereis(myprocess)]).

运行上面代码输出

当我们运行上述程序时,我们将得到以下输出。

<0.55.0>
"hello"

参考链接

www.learnfk.com/erlang/erla…