I am new to Android Application development and was having a problem with Async tasks. 
So I'm trying to create an ECG graphing application that does some background processing while the graphing is happening. 

I've defined the following Async task - 

```
private class Erosion extends AsyncTask <Void,Void,Void> {

    @Override
    protected Void doInBackground(Void...unused ) {

        int i,tempIndex;
        double[] tempArray = new double[13];
        double min = ecgSamples[ecgSampleForErosionIndex] - gArray[0]; 
        while (ecgIncoming)
        {
            if (ecgSampleForErosionIndex > 179999)
            {
                ecgSampleForErosionIndex = 0; 
            }

            for(i= 0;i<13;i++)
            {
                tempIndex = ecgSampleForErosionIndex + i; 
                if (tempIndex > 179999)
                {
                    tempIndex =  (ecgSampleForErosionIndex + i) - 180000;
                }
                tempArray[i] = ecgSamples[tempIndex] - gArray[i];
                if (tempArray[i] < min)
                {
                    min = tempArray[i];
                }

            }

            //min needs to be stored in the erosionFirst Array

            if (erosionFirstArrayIndex > 179999)
            {
                erosionFirstArrayIndex = 0; 
            }

            ecgErosion[erosionFirstArrayIndex] = min; 
            erosionFirstArrayIndex++;
            ecgSampleForErosionIndex++;

        }
        return null;

    }

    } //End of Async Task  

```

So all I'm trying to do is modify the content of a particular array in the async task - i dont need to update the UI (at least not for now) 

However, when I run this async task my ECG graphing slows down and becomes jerky. When I comment out the "new Erosion().execute();" part in the code where I start the Async task, the graphing becomes normal again. 

Isn't an async task supposed to be on a separate thread and so not affecting how things are happening on my UI thread? What am I doing wrong?