it_worker365

   ::  ::  ::  ::  :: 管理

异步回调

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();
    }
}

 

posted on 2015-06-22 22:44  it_worker365  阅读(134)  评论(0编辑  收藏  举报