首页 > 其他分享 >无涯教程-Erlang - spawn函数

无涯教程-Erlang - spawn函数

时间:2023-12-07 21:32:06浏览次数:45  
标签:spawn Function erlang 无涯 server start Erlang Hello

这用于创建新进程并对其进行初始化。

spawn - 语法

spawn(Function)
  • Function  -  需要产生的功能。

spawn - 返回值

此方法返回一个进程ID。

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

start() ->
   spawn(fun() -> server("Hello") end). 

server(Message) ->
   io:fwrite("~p",[Message]).

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

“Hello”

参考链接

https://www.learnfk.com/erlang/erlang-spawn.html

标签:spawn,Function,erlang,无涯,server,start,Erlang,Hello
From: https://blog.51cto.com/u_14033984/8727948

相关文章

  • 无涯教程-Erlang - unregister函数
    这用于注销系统中的进程。unregister-语法unregister(atom)atom-这是要赋予该过程的注册名称。unregister-示例-module(helloLearnfk).-export([start/0,call/2]).call(Arg1,Arg2)->io:fwrite("~p~n",[Arg1]).start()->Pid=spawn(?MODULE,cal......
  • 无涯教程-Erlang - register函数
    这用于在系统中注册进程。register-语法register(atom,pid)atom-这是要赋予该过程的注册名称。pid  -这是需要绑定到原子的进程ID。register-示例-module(helloLearnfk).-export([start/0,call/2]).call(Arg1,Arg2)->io:fwrite("~p~n",[Arg1]).......
  • 无涯教程-Erlang - is_pid函数
    此方法用于确定进程ID是否存在。is_pid-语法Is_pid(processid)processid  - 这是需要检查的进程ID,是否存在。is_pid-返回值如果进程ID存在,则返回true,否则将返回false。-module(helloLearnfk).-export([start/0,call/2]).call(Arg1,Arg2)->io:format("......
  • 无涯教程-Erlang - binary_to_list函数
    此方法用于将二进制值转换为列表。binary_to_list-语法binary_to_list(binaryvalue)binaryvalue- 这是需要转换为列表的二进制值。binary_to_list-返回值返回列表。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~p~n",[binary_to_lis......
  • 无涯教程-Erlang - is_binary函数
    此方法用于检查位串是否确实是二进制值。is_binary-语法is_binary(bitstring)bitstring-这是需要检查其是否为二进制的位串。is_binary-返回值如果位串是二进制值,则返回true;否则返回false。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("......
  • 无涯教程-Erlang - term_to_binary函数
    此方法用于将术语转换为二进制。term_to_binary-语法term_to_binary(term)term-这是需要转换为二进制值的术语值。term_to_binary-返回值根据指定的术语返回一个二进制值。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~p~n",[term_to......
  • 无涯教程-Erlang - memory函数
    返回一个列表,其中包含有关由Erlang动态分配的内存的信息,该列表的每个元素都是一个元组{Type,Size},第一个元素Type是描述内存类型的原子。memory-语法memory()memory-返回值返回一个列表,其中包含有关由Erlang仿真器动态分配的内存的信息。-module(helloLearnfk).-export......
  • 无涯教程-Erlang - element函数
    该方法返回元组中的第Nth元素。element-语法element(N,Tuple)N    -元组中需要返回的位置。Tuple -需要为其返回第N元素的元组。element-返回值该方法返回元组中的第Nth元素。-module(helloLearnfk).-export([start/0]).start()->io:......
  • 无涯教程-Erlang - tuple_to_list函数
    此方法将元组转换为列表。tuple_to_list-语法tuple_to_list(list)list - 这是需要转换为列表的元组。tuple_to_list-返回值根据提供的元组返回一个列表。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~w",[tuple_to_list({1,2,3})]).......
  • 无涯教程-Erlang - list_to_tuple函数
    此方法是将列表转换为元组。list_to_tuple-语法list_to_tuple(list)list - 这是需要转换为元组的列表。list_to_tuple-返回值根据提供的列表返回一个元组。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~w",[list_to_tuple([1,2,3])])......