0

On main Activity, I do the following to have these methods run in the background thread.

private void doInBackground() {
      final Activity a = this;
      AsyncTask.execute(new Runnable() {
         @Override
         public void run() {
            bindDb();
            new MessageSynchronizer(a);
            NotifHelper.cancelNotifications(a);
            MessageHelper.updateMyLastSeen();
            versioning();
         }
      });
}

Then I want to know if the following method, called from above is running in the UiThread or the thread which called it above.

private void bindDb() {
      DatabaseHelper databaseHelper = new DatabaseHelper(this);
      databaseHelper.getWritableDatabase();
      databaseHelper.getDatabaseName();
      databaseHelper.close();
}
Relm
  • 7,923
  • 18
  • 66
  • 113

1 Answers1

2

It's on the background thread, i.e. the thread used by ASyncTask. That's due to pure Java execution semantics: a method being invoked by a method running on a thread gets executed on the same thread.

You can also verify this by checking the current thread as shown in this post.

Community
  • 1
  • 1
M A
  • 71,713
  • 13
  • 134
  • 174