Unity: Android "main" (UI) thread

All Android apps have a “Main” thread that handles all the UI. This is how the Android OS tests if an app is responsive or not. (see more here: Android Developers Blog: Painless threading )

I’m sometimes getting “Application Not Responding” on my app, which appears to be originating in java plugins, so I need to know a few things about Unity.

My questions are:

Which android thread does the Unity engine run on?

I know that all unity script code runs on a single thread; is this the same thread as the engine? Is it the “main” android thread?

When calls are made to native java android plugins, does it run the java code in a different thread? (It seems to be asynchronous as near as I can tell, but then it doesn’t make any sense to me how the java plugin could be on the main thread, as is shown in the ANR report)

Bitter answered this in the forum ( http://forum.unity3d.com/threads/unity-android-main-ui-thread.174553/ )

“Unity is using it’s own threads to do the processing required by the engine. It’s not entirely true that unity scripting is bound to be single threaded - but yes, if you call into java from a unity script it will be the same thread executing that java function as were executing the script.”

@cowlinator , You might find AndroidJavaRunnable useful.