-module(newbie). -compile([export_all]). starter() -> spawn(?MODULE, the_first_p, []). the_first_p() -> register(pidfirstp, self()), spawn_link(?MODULE, the_second_p, []), receive {From, "to first p", Msg} -> From ! {self(), "the_first_p()", Msg} end, the_first_p(). the_second_p() -> register(pidsecondp, self()), spawn_link(?MODULE, the_third_p, []), receive {From, "to second p", Msg} -> From ! {self(), "the_second_p()", Msg} end, the_second_p(). the_third_p() -> register(pidthirdp, self()), receive {From, "to third p", Msg} -> From ! {self(), "the_third_p()", Msg} end, the_third_p(). call_the_first() -> pidfirstp ! {self(), "to first p", "Halo first p!"}, receive {Pid, FuncName, Msg} -> {Pid, FuncName, Msg} end. call_the_second() -> pidsecondp ! {self(), "to second p", "Halo second p!"}, receive {Pid, FuncName, Msg} -> {Pid, FuncName, Msg} end. call_the_third() -> pidthirdp ! {self(), "to third p", "Halo third p!"}, receive {Pid, FuncName, Msg} -> {Pid, FuncName, Msg} end.