spawn(Fun) -> pid()
参数类型:
Fun = function() %% 参数为空的函数
返回类型:
进程Pid
说明:生成一个由Fun函数启动的、参数为空的新进程,并返回进程的Pid。
spawn(Node, Fun) -> pid()
参数类型:
Node = node() %% 节点
Fun = function() %% 参数为空的函数
返回类型:进程Pid
说明:生成一个由在Node节点上,由Fun函数启动的、参数为空的新进程,并返回进程的Pid。
spawn(Module, Function, Args) -> pid()
参数类型:
Module = module() %% 模块名
Function = atom() %% 原子函数名
Args = [term()] %% 参数列表
返回类型:进程Pid
说明:生成一个由Module:Function函数启动的、参数为Args列表的新进程,并返回进程的Pid。
新的进程会被放入系统的调度队列之中,延后创建。
error_handler:undefined_function(Module, Function, Args) is evaluated by the new process if Module:Function/Aritydoes not exist (where Arity is the length of Args). The error handler can be redefined (see process_flag/2). If error_handler is undefined, or the user has redefined the default error_handler its replacement is undefined, a failure with the reason undef will occur.
> spawn(speed, regulator, [high_speed, thin_cut]).
<0.13.1>
spawn(Node, Module, Function, Args) -> pid()
Types:
Node = node()
Module = module()
Function = atom()
Args = [term()]
返回类型:进程Pid
说明:生成一个在Node节点上,由Module:Function启动的、参数为Args列表的新进程,并返回进程的Pid。
如果Node不存在,会返回一个没用的pid。其他情况和spawn/3一样。
hzhsan注:函数不等于函数的返回值。参数是表达式,如果这个表达式的结果应该是个函数,那么就不能是函数的返回值。