你在B,C机器上设置timeout不就行了。<div><br></div><div><div>receive</div><div>{Pid,okss} -></div><div>              io:format("~p~n", [{Pid,Any}]),</div><div>              Pid ! "thank you",</div><div>              loop()</div>
<div>after Timeout -></div><div>        dosothing here</div><div>end.</div><br><div class="gmail_quote">2013/1/9 郎咸武 <span dir="ltr"><<a href="mailto:langxianzhe@gmail.com" target="_blank">langxianzhe@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">假如有三台服务器A,B,C做一个集群。<div>在其中A 服务器上运行下面代码。</div><div>这是 三台服务器都能使用 gl进程发送消息。</div><div><br></div><div><b>问题是: </b>A 服务器挂掉后,B和C 两台服务器都不能正常使用.</div>
<div><br></div><div>请问有什么好的方法避免这个问题?</div><div><div><br></div><div>谢谢各位</div><div>
<br></div><div>郎咸武</div><div><br></div><div><br></div><div><div>  1 -module(global_t).                                                                                                                                                                                              </div>

<div>  2 </div><div>  3 -compile(export_all).</div><div>  4 </div><div>  5    </div><div>  6 start() -></div><div>  7     Pid = spawn(?MODULE, loop, []),</div><div>  8     global:register_name(gl, Pid). </div><div>  9 </div>

<div> 10 </div><div> 11 loop() -></div><div> 12     io:format("loop~n", []),</div><div> 13     receive </div><div> 14         {Pid,Any} -></div><div> 15             io:format("~p~n", [{Pid,Any}]),</div>

<div> 16             Pid ! okss,</div><div> 17             loop()</div><div> 18     end.</div><div> 19 </div><div> 20 </div><div> 21     </div><div>~                                                                                                                                                                                                                   </div>

<div>~                                                                                                                                                                                                                   </div>

<div>~                   </div></div><span class="HOEnZb"><font color="#888888">-- <br>只为成功找方法,不为失败找理由
</font></span></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>