异步回调
A请求B,B处理后再通知A
public interface ICallback { public void callback(); }
public class CallbackImpl implements ICallback { @Override public void callback() { System.out.println("callbackimpl"); } public static void main(String[] args) { Caller caller = new Caller(new CallbackImpl()); caller.call(); } }
public class Caller { private ICallback callback; public Caller(ICallback callback) { this.callback = callback; } public void call(){ this.callback.callback(); } }