乒乓球问题,指方法的来回调用.
public class Boy extends Actor{ @Override public void send(String message,Actor to){ pln(this.name+" To "+to.name+":\""+message+"\""); to.receive(message,this); } @Override public void receive(String message,Actor from){ char c = (char)(Math.random()*4+'a'); if(c!='b'){ String msg = message+" "+c; send(msg,from); } } }对象a. send(String message,Actor to)代码中b..receive(message,this),而b.receive()代码中自己又send()。
原文地址:http://blog.csdn.net/yqj2065/article/details/39591119