The code architecture of***ResponseHandler
阿新 • • 發佈:2019-02-05
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 ;.
}
}
}
}