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();
}