无涯教程-Erlang - unregister函数

32 阅读1分钟

这用于注销系统中的进程。

unregister - 语法

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

unregister - 示例

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

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

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

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

<0.55.0>
"hello"
Undefined

参考链接

www.learnfk.com/erlang/erla…