Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(ex3).
- -compile(export_all).
- loop() ->
- receive
- {print, Msg} ->
- io:format("~s~n", [Msg]),
- loop();
- exit -> ok
- end.
- start(AnAtom, Fun) ->
- global:trans({funLock, AnAtom}, fun() ->
- case global:whereis_name(AnAtom) of
- undefined ->
- Pid = spawn(Fun),
- global:register_name(AnAtom, Pid);
- _ ->
- io:format("Function already registered.~n")
- end end).
Add Comment
Please, Sign In to add comment