0

I'm trying to make my Android app more responsive and to do so I'm using multithreading; I know thread dispatching is controlled by OS, and such responsibility is on OS thread scheduler's hands, we can't assign them directly.

After some runs I got the feeling my threads was running in a single core, just to save power because they're dependent of each other (producer/ consumer pattern here), that makes totally sense to me.

Also I've read some Stack Overflow post just to confirm my feeling, such as

Are new threads automatically assigned to a different CPU Core in Java?

Threads automatically utilizing multiple CPU cores?

And some others that I won't post here =)

Also I've read this one too Android: Find out which core the thread is running on

So my question is:

From your experience what's a good approach to optimize such thing? Also I never used NDK with Android app, what's the best source to read about NDK usage? I've C++ baggage by the way.

And there's another way to know what core each thread is running?

Community
  • 1
  • 1
  • The first step is to find out what's making your app slow, and determine whether it could benefit from multithreading. Have you done that? – Kevin Krumwiede Sep 24 '16 at 03:12
  • @Kevin, Yes I did, most of my code was tested before (most of I've used on my job). I'm dealing with a lot of HttpRequest so I decide to use some multithreading to see if I could get more juice here =) – Tadeu Arias Villares Sep 24 '16 at 06:32

1 Answers1

0

HttpRequest most time spends waiting for reply from server. For that time, thread releases the processor, so even if your application is provided with single core, multiple threads can run in parallel. You should care to occupy more than one core only if your application does intensive number computations. My suggestion is that you make Http Requests serially, and not in parallel, and this is the reason your application is not responsive.

Alexei Kaigorodov
  • 13,189
  • 1
  • 21
  • 38