這用于在節(jié)點(diǎn)上創(chuàng)建新進(jìn)程。
spawn(Node,Function)
Node ?需要在其上生成函數(shù)的節(jié)點(diǎn)。
Function ?需要派生的函數(shù)。
此方法返回一個(gè)進(jìn)程ID。
-module(helloworld).
-export([start/0]).
start() ->
spawn(node(),fun() -> server("Hello") end).
server(Message) ->
io:fwrite("~p",[Message]).輸出結(jié)果
當(dāng)我們運(yùn)行上面的程序時(shí),我們將得到以下結(jié)果。
“Hello”