In my Android app, I have a snippet of code, similar to Run code for x seconds in Java?
long t= System.currentTimeMillis();
long end = t+15000;
while(System.currentTimeMillis() < end) {
//useful calculation
}
And this code will freeze the UI thread, so I'm wondering if there's a way to continuously pass in data to my AsyncTask that will do the calculation in the background thread to avoid freezing? Or is there a better way, or to keep calling AsyncTask from within my while loop?