【发布时间】:2011-02-17 16:39:01
【问题描述】:
如果我从一个函数中调用(全部用 Java 编写):
public int hello() {
int a = 1;
executeCallback();
// C: Question lies in this range
return a;
}
public void executeCallback() {
// A: random code to execute before asynccallback
randomClass.randomMethod(int a, int b, AsyncCallback<ReturnType>() {
onSuccess();
onFailure();
});
// B: random code to execute after asynccallback
}
我知道注释A中的东西会执行,同时非同步randomMethod会执行,B中的注释也会执行。
不过,我想知道,当 randomMethod 正在执行时(如果它需要足够长的时间),该函数是否会返回到它的调用者(在本例中为方法 'hello')并开始执行注释 C 中的代码?还是executeCallback会等待randomMethod完成后再返回?
如果是前者,假设我需要在继续评论 C 之前触及 randomMethod 所触及的信息,我怎样才能让它“等待”以确保会是这种情况?
【问题讨论】:
标签: gwt asynccallback