Is there a better way to listen for a condition variable in a background thread?
<p>I need to wait for a GPS signal to be acquired by my location handler class before assigning the latitude and longitude to an api query class. In this inner class I'm using a background process to wait until the variable is changed from null before passing it into the API class. I'm sure there might be a more efficient way to do this, but I don't see what it is. </p>

<pre><code>private class listenForLocation extends AsyncTask&lt;Activity, Void, locationHandler&gt; {

protected locationHandler doInBackground(Activity... params) {
        locationHandler curLoc = new locationHandler(params[0]);
        curLoc.askForlocation();
        while (curLoc.getCurrentLong() == null){
            // wait for an actual location update
        }
        return curLoc;
    }//doInBackground

    @Override
    protected void onPostExecute(locationHandler result) {
        yelpDataExecutor load = new yelpDataExecutor();
        load.execute(result.getCurrentLat(),result.getCurrentLong());

    }//On Post Execute

}//listen for location Class
</code></pre>