3

I have a question regarding IntentService

Let's say I have two intent service classes that do separate tasks unrelated to each other.

public class TaskA extends IntentService{
    @Override
    protected void onHandleIntent(Intent workIntent) {}        
}

And the second

public class TaskB extends IntentService{
    @Override
    protected void onHandleIntent(Intent workIntent) {}            
}

If I start TaskA first and then next line start TaskB, would TaskB have to wait for TaskA to finish?

I am aware that if I start the same intent service again, it is added to a queue but does this apply to an instance or is a global to the whole application?

jww
  • 97,681
  • 90
  • 411
  • 885
Ersen Osman
  • 7,067
  • 8
  • 47
  • 80

2 Answers2

2

If I start TaskA first and then next line start TaskB, would TaskB have to wait for TaskA to finish?

Each IntentService has its own worker thread. Specifically, it is an instance of HandlerThread, as seen in the source code to IntentService. Hence, one IntentService's onHandleIntent() should not block another IntentService's onHandleIntent().

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

From the documentation:

All requests are handled on a single worker thread -- they may take as long as necessary (and will not block the application's main loop), but only one request will be processed at a time.

StenSoft
  • 9,369
  • 25
  • 30