发送消息Pid Erlang [英] Sending message Pid Erlang
问题描述
我确实启动了一个进程,输出显示pid为< 0.39.0>。
我的问题是如何手动发送一个消息到这个过程(<0.39.0>)。
Anyhelp将不胜感激
虽然 list_to_pid / 1
确实可以用来构造PID并使用它发送不鼓励使用它的用法:
此BIF旨在用于Erlang运行
系统的调试和使用。不应该在应用程序中使用。
更好的方法是在启动过程时保存PID:
1> P = spawn(fun() - > receive _ - > ok end end)。
< 0.34.0>
2> P!喜。
hi
I would like to know, how can i send a message to process with erlang. I did start a process and the output shows me that the pid is <0.39.0>. My problem is how can i send a message to this process (<0.39.0>) manually.
Anyhelp would be appreciated
While list_to_pid/1
can indeed be used to construct a PID and use it to send messages its usage is discouraged:
This BIF is intended for debugging and for use in the Erlang operating system. It should not be used in application programs.
A better approach would be to save the PID when you start the process:
1> P = spawn(fun() -> receive _ -> ok end end).
<0.34.0>
2> P!hi.
hi
这篇关于发送消息Pid Erlang的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!