Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android how many threads can I have going?

I have an Android app that has separate things going on but are all basically threads (and definitely are threads to the Android debugger)

There are multiple animation listeners that loop and call each other

There is a countdown timer that is always counting down to zero after it is initiated

Now I need to consider adding more countdown timers. How many of these kind of looping processes can I have going on? In this particular implementation I am not concerned about performance, efficiency, etc, until it becomes apparent.

Insight appreciated

like image 250
CQM Avatar asked Sep 28 '11 18:09

CQM


People also ask

How many threads can Android run?

Seven Threading Patterns in Android.

Is Android multi threaded?

Concurrency means running multiple tasks in parallel, it is one of the main reasons that we use threads. As Android is a single-threaded model, we need to create different threads to perform our task and post the result to the main thread where the UI gets updated.

What are the rules for Android threads?

Thus, there are simply two rules to Android's single thread model: Do not block the UI thread. Do not access the Android UI toolkit from outside the UI thread.

Is threads available on Android?

Making adept use of threads on Android can help you boost your app's performance. This page discusses several aspects of working with threads: working with the UI, or main, thread; the relationship between app lifecycle and thread priority; and, methods that the platform provides to help manage thread complexity.


1 Answers

I would be very surprised to learn that you exhausted the number of threads you can use safely in an android application, as long as you are properly managing their lifetime and prevent "busy loops"and the like from occuring.

One thing I did learn though, I am pretty sure you can only have 5 asynctasks operational at any time, and they will arbitrarily continue to exist and get killed or respawned by themselves if you start new ones...ie if i turned an asynctask on then off five times the debugger will say 5 async threads operational, but I can continually toggle on and off as much as I want because the resource pool will kill the oldest dead asynctask.

like image 85
hinklecw Avatar answered Sep 27 '22 19:09

hinklecw