1. 程式人生 > >The code architecture of***ResponseHandler

The code architecture of***ResponseHandler

public class ***ResponseHandler <T> implement IAsyncCallback {

//condition can wait a certain time  and then  continue current thread, if wiithout any condition.signal();

private Condition condition;

<T> get(){

...

condition.await(...)// where the thread will be blocked a certain time, if without condition.signal();


...

}

 
    public void response(Message message) {
      
            if (!done.get()) {
               
                responses.add( message );
                
                if (responses.size() >= quorum...) {
                    done.set(true);
                    condition.signal();    // to notify the thread of get()

  to continue ;.       
            }
     
    }

}

}