我知道 RPC 是异步的,但是如何以其他方式(除了等待响应)来解决这个问题:
public static String htsl(String sentence)
{
final DataBaseAsync db = GWT.create(DataBase.class);
String cookie = staticContent.getCookie("ll");
String shortcut = cookie.split("/")[1];
final String[] lala = new String[1];
database.getTranslated(sentence, shortcut, new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
lala[0]=result;
//this result I want to return in static function htsl... ?
}
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
});
//here I have blank result, because RPC is slower than te return..
And i have always blank result
return lala[0];
}
我知道这不好,但是..如果这没有可行的解决方案,如何等待响应?