I know an IntentService itself runs on a different thread.
Also that it execute the onHandleIntent() and stops when that method is done.
my question is: are there any consequences for creating my own custom Thread inside the intent service?
I know it can be done in a Service but I want to know if thats a wrong way of using IntentService
for a bit more information what I need to do is to send lots of HTTP requests.
What im about to do is save on a DB the request strings, and run intent service that execute them. That's why I use IntentService, the requests might take time and I want the service to shut down once the table containing the requests is empty.
I thought i might increase the speed of this service by adding my own threads to it as I will be running lets say, 5 threads each time.
EDIT: This is the code I thought to do, I guess it will clear things about what im trying to do and if its possible.
protected void onHandleIntent(Intent intent) {
helper = new DBHelper(getApplicationContext());
File file;
//checks if the DB requests exists
while(helper.requestsExists()){
ArrayList<String> requestArr = helper.getRequestsToExcute(5);
if(!requestArr.isEmpty()){
//execute them and delete the DB entry
for(int i=0;i<requestArr.size();i++){
file = new File(requestArr.get(i));
new MyThread(file).start();// the DB entry is delete withing the thread
}
}
}
}
so this service will run as long as it got any DB entries on my SQLite db, after it will finish executing all of them it will stop. is it ok or should i use Service for it?