Guest User

Untitled

a guest
Feb 20th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. -module(ex3).
  2. -compile(export_all).
  3.  
  4. loop() ->
  5. receive
  6. {print, Msg} ->
  7. io:format("~s~n", [Msg]),
  8. loop();
  9. exit -> ok
  10. end.
  11.  
  12. start(AnAtom, Fun) ->
  13. global:trans({funLock, AnAtom}, fun() ->
  14. case global:whereis_name(AnAtom) of
  15. undefined ->
  16. Pid = spawn(Fun),
  17. global:register_name(AnAtom, Pid);
  18. _ ->
  19. io:format("Function already registered.~n")
  20. end end).
Add Comment
Please, Sign In to add comment