https://blog.csdn.net/hzhsan/article/details/50377508
spawn(Fun) -> pid()
參數(shù)類型:
Fun = function() %% 參數(shù)為空的函數(shù)
返回類型:進(jìn)程Pid
說(shuō)明:生成一個(gè)由Fun函數(shù)啟動(dòng)的、參數(shù)為空的新進(jìn)程,并返回進(jìn)程的Pid。spawn(Node, Fun) -> pid()
參數(shù)類型:
Node = node() %% 節(jié)點(diǎn)
Fun = function() %% 參數(shù)為空的函數(shù)
返回類型:進(jìn)程Pid
說(shuō)明:生成一個(gè)由在Node節(jié)點(diǎn)上,由Fun函數(shù)啟動(dòng)的、參數(shù)為空的新進(jìn)程,并返回進(jìn)程的Pid。
spawn(Module, Function, Args) -> pid()
參數(shù)類型:
Module = module() %% 模塊名
Function = atom() %% 原子函數(shù)名
Args = [term()] %% 參數(shù)列表
返回類型:進(jìn)程Pid
說(shuō)明:生成一個(gè)由Module:Function函數(shù)啟動(dòng)的、參數(shù)為Args列表的新進(jìn)程,并返回進(jìn)程的Pid。
新的進(jìn)程會(huì)被放入系統(tǒng)的調(diào)度隊(duì)列之中,延后創(chuàng)建。
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()]
返回類型:進(jìn)程Pid
說(shuō)明:生成一個(gè)在Node節(jié)點(diǎn)上,由Module:Function啟動(dòng)的、參數(shù)為Args列表的新進(jìn)程,并返回進(jìn)程的Pid。
如果Node不存在,會(huì)返回一個(gè)沒(méi)用的pid。其他情況和spawn/3一樣。
hzhsan注:函數(shù)不等于函數(shù)的返回值。參數(shù)是表達(dá)式,如果這個(gè)表達(dá)式的結(jié)果應(yīng)該是個(gè)函數(shù),那么就不能是函數(shù)的返回值。
posted on 2018-04-10 14:27
思月行云 閱讀(768)
評(píng)論(0) 編輯 收藏 引用 所屬分類:
Erlang