You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
webcrawler/core/src/main/java/core/thrift/MyAsyncMethodCallback.java

34 lines
644 B

6 years ago
package core.thrift;
import org.apache.thrift.async.AsyncMethodCallback;
public class MyAsyncMethodCallback<E> implements AsyncMethodCallback<E> {
private boolean onComplete=true;
private E result;
public E getResult() throws InterruptedException {
6 years ago
while (result==null&&onComplete){
6 years ago
Thread.sleep(100);
}
return result;
}
6 years ago
6 years ago
@Override
public void onComplete(E o) {
onComplete=false;
result=o;
}
@Override
public void onError(Exception e) {
e.printStackTrace();
}
6 years ago
public void setResult(E result) {
this.result = result;
}
6 years ago
}