iOS は非同期メソッドを開始し、nsrunloop を使用してメイン スレッドで待機できます。
while(!iterationDone) {
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.5]];
//do other stufff
}
これにより、uithread は生き続けることができ、多くの非同期メソッドを呼び出すシーケンスを維持できます。同期メソッドのように簡単に呼び出すだけです。
public int asyncmethod1{
new Handler.post(new Runnable() {
@Override
public void run() {
// Do something on the UI-Thread
}
});
//while(handler is end)
//return the result
}
public void main(){
int i= asyncmethod1();
i+=asyncmethod2();
}
ただし、このメソッドは uithread が応答しない原因である必要があります。