Kevin
Kevin

Reputation: 129

What gets killed with the Android UI thread

In an activity, I spin off several separate threads. Later, on one of these child threads, I make the following call:

((Activity) context).runOnUiThread(new Runnable() {
    public void run() {
        String message = "Exception thrown: Developer mode was enabled while " +
            "trying to access the app.";
        throw new RuntimeException(message);
    }
});

Now, what else will be killed along with the UI thread? Will the other threads die as well? When the app crashes, it's still running in the background (I think)

Upvotes: 4

Views: 290

Answers (1)

Lino
Lino

Reputation: 6160

I think all the threads related to that process will be killed (in a single process model scenario). You can verify it by running

ps -t | grep [your-app-user-id]

from the command line before and after the RuntimeException

To get the app's user id:

ps | grep [your-package-name]

Upvotes: 1

Related Questions