I tried to do heavy process in background to avoid UI lag. When i do it in UI Thread, i got not responding, but when i do it in asyntask there is no not responding anymore, but the UI still lag and stuck for some time. This is my code.

```
private class GenerateTask extends AsyncTask<String, Integer, Void> {
        @Override
        protected final Void doInBackground(String... lists) {
            for (int j = 0; j < 9000; j++) {
                final Keyword newKeyword = new Keyword();
                newKeyword.setId(j);
                newKeyword.setQuestion_answer_id(j);
                newKeyword.setKeyword("Keyword ke " + j + " " + UtilHelper.getLocation(j % 9));
                newKeyword.setUpdated_at(UtilHelper.getDateTime());
                //i think this is the one who causes the lag, but i still need this run on ui thread
                getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        UtilDB db = new UtilDB(getActivity().getApplicationContext());
                        db.replaceKeyword(newKeyword);
                    }
                });
            }
            progressDialog.dismiss();
            return null;
        }
    }

```