Hello,
Check your AMDataSend class. Probably it's waiting for something or has an infinite loop inside. You can modify your termination check loop as follows to forecefully terminate the worker threads.
int cntr = 0;
executor.shutdown();
while (!executor.isTerminated() || cntr < 3) {
boolean awaitTermination = executor.awaitTermination(1000, TimeUnit.MILLISECONDS);
if (awaitTermination) {
break;
}
cntr++;
}
try {
if (!executor.isTerminated()) {
executor.shutdownNow();
executor.awaitTermination(1000, TimeUnit.MILLISECONDS);
}
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
Regards,