Hello. I have to stop all the threads from an ExecutorService object. I
used the example from
http://developer.android.com/reference/java/util/concurrent/ExecutorService.html#awaitTermination(long,
java.util.concurrent.TimeUnit)
and only 1 out if 15 threads was terminated. Why?
Is it a better idea to solve my task such a way?
public void stopThreads() {
Log.i(Constants.LOG_TAG, "Stop threads:
ServerInteraction::stopInteraction()");
isCancelling = true;
mPoolThreads.shutdown(); // Disable new tasks from being submitted
boolean isTerminated = mPoolThreads.isTerminated();
while (!isTerminated) {
mPoolThreads.shutdownNow();
isTerminated = mPoolThreads.isTerminated();
Log.i(Constants.LOG_TAG, "Stop threads: the threads are not
terminated yet");
}
Log.w(Constants.LOG_TAG, "Stop threads: Terminated");
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en