English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang 进程 whereis 方法

Erlang 进程

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

语法

whereis(atom,pid)

参数

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

返回值

绑定到原子的进程ID。

-module(helloworld). 
-export([start/0, call/2]). 
call(Arg1, Arg2) -> 
   io:fwrite("~p~n",[Arg1]). 
start() -> 
   Pid = spawn(?MODULE, call, ["hello", "process"]), 
   register(myprocess, Pid), 
   io:fwrite("~p~n",[whereis(myprocess)]).

当我们运行上面的程序时,我们将得到以下结果。

<0.55.0>
"hello"

Erlang 进程