我该如何避免这种忙碌的等待?

nge*_*esh 3 java multithreading android

public int getChildrenCount(int groupPosition) {
    if(children == null){
        new SalesRequest().execute(); // runs in other thread which 
                                      // initialises children with some value.
        while(children == null){
            // I'm doin this to avoid null pointer Exception.
            // So it comes out of the loop only when childern 
            // gets initialised.
        }
    }
    return children.length;
}
Run Code Online (Sandbox Code Playgroud)

但我对我处理这个问题的方式并不满意.有一个更好的方法吗?