func(X) ->
receive % This checks the whole mailbox for 'die'
die -> dead;
after 0 -> % No 'die' message in mailbox, process the next Message whenever it arrives
receive % This checks only the next Message in the mailbox
die -> dead;
Message -> func(do_something(X, Message))
end
end.
1条答案
按热度按时间yhived7q1#
对于您的代码,您是忙碌等待的,您可以执行以下操作: