Any suggestion on how do we kill a thread which has made a http post request and waiting till getting response. I want to kill this thread from another thread running parallely before it could receive any response from request. I got suggestion to close or abort the http post request but did not workout, can anyone suggest how can we abort the http request in this scenario or any other way to achieve this.
The thread that made the request is blocked while waiting the server to respond. If you take a thread dump and see, it will be in some read() method, but not on a Thread.sleep. So calling interrupt() will not have an effect (unless it's an InterruptibleChannel). Do you have access to the socket or the output stream on which the POST request was made? If so, you can close that, which will bring out of the read wait with an exception. Do you have a code sample that you can put up?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With