[erlang-questions] Receiving identical messages from Erlang and from JInterface

Richard Carlsson richardc@REDACTED
Thu Jan 4 17:27:05 CET 2007

Erlang list wrote:
> However, when I do the same but send the 
> messages from a Java program using JInterface the first message is 
> received but pattern matching for the second message seems to fail:
> (foo@REDACTED)113> process_info(self(), messages).
> {messages,[{<4999.1.0>,hello},{<4999.1.0>,hello}]}
> (foo@REDACTED)114> receive {P,X} -> {P,X} after 2000 -> false 
> end.
> {<4999.1.0>,hello}
> (foo@REDACTED)115> b().
> P = <4999.1.0>
> X = hello
> ok
> (foo@REDACTED)116> receive {P,X} -> {P,X} after 2000 -> false 
> end.
> false
> (foo@REDACTED)117> process_info(self(), messages).
> {messages,[{<4999.1.0>,hello}]}

Try using different variable names in the second receive, e.g. {P1,X1}.
This should make it extract the second message from the mailbox. Then
you can check whether P =:= P1, which is probably not the case since
you got this problem. After that, perhaps term_to_binary(P) and 
term_to_binary(P1) might give more information about what is happening.


More information about the erlang-questions mailing list