-1

In a FOR loop within one of my bound services, I make another call to another bound service. I get the error "rejected from java.util.concurrent.ThreadPoolExecutor". I know this is because there are not enough threads to execute my tasks. I'm a bit confused regarding thread pools but I know I need something like this to make the threads wait.

How can I make the messages wait (below) for a free thread before sending a message to the service?

Message message = Message.obtain(null, TwitterService.REQUEST, 0, 0);
SendFBIDParcel parcel = new SendFBIDParcel();
parcel.id = item.getGivenID();

Bundle bundle = new Bundle();
bundle.putParcelable("id", parcel);
message.setData(bundle);

try {
   messenger.send(message);
   counter++;
} catch (RemoteException e) {
   e.printStackTrace();
}
Serafins
  • 1,237
  • 1
  • 17
  • 36
Natalia Sharon
  • 216
  • 2
  • 17

1 Answers1

0

You can use AsyncTaskto perform it.

Check : http://developer.android.com/reference/android/os/AsyncTask.html

There's an example here: http://programmerguru.com/android-tutorial/android-asynctask-example/

You've got this message beacuse you have exceeded the number of tasks for the ThreadPoolExecutor

Hope it helps.

Nicolas Cortell
  • 659
  • 4
  • 16