Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(sleeperl).
- -compile(export_all).
- testa() ->
- lists:map(fun(_) ->
- os:cmd("/bin/sleep 0.1")
- end, lists:seq(1, 50)).
- testb() ->
- io:format("Receiver spawned at ~p~n", [now()]),
- Recv = spawn(fun() ->
- thisloop([])
- end),
- io:format("Spawn start at ~p~n", [now()]),
- lists:map(fun(_) ->
- spawn(fun() ->
- os:cmd("/bin/sleep 3"),
- Recv ! {done, self()}
- end)
- end, lists:seq(1, 5)),
- io:format("Spawn done at ~p~n", [now()]).
- thisloop(Acc) ->
- NewAcc = receive
- X ->
- io:format("receiver got '~p' at ~p~n", [X, now()]),
- [X | Acc]
- end,
- thisloop(NewAcc).
Add Comment
Please, Sign In to add comment