[erlang-questions] spawn race condition?
Oscar Hellström
oscar@REDACTED
Tue Apr 3 20:05:11 CEST 2007
On Wed, 4 Apr 2007 04:01:16 +1100
Anthony Shipman <als@REDACTED> wrote:
> I have code that looks like this:
>
> call(Phone) ->
> Pid = spawn(?MODULE, init, [Phone]),
>
> util:delay(100),
> Pid! {startCall, self()},
> receive
> callComplete -> {ok, Pid}
> after
> 5000 -> false
> end.
>
> If I don't have the 100ms delay then the only message that the new process
> receives is the integer 0. It works with the delay. Am I missing something?
What exactly does init/1 do? You are indeed supposed to be able to send
messages to processes without delays. Are there any other processes
sending the spawned processes if it would return {ok, Pid}? Does init
somehow flush the message queue?
> --
> Anthony Shipman Mamas don't let your babies
> als@REDACTED grow up to be outsourced.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
--
Oscar Hellström, oscar@REDACTED
Erlang Training and Consulting
http://www.erlang-consulting.com/
More information about the erlang-questions
mailing list