开发者

Java: How to issue an http request asynchronously?

I've been searching around trying to find a straightforward solution to submitting an http request asynchronously in java, but haven't had any luck. I actually don't even care about the response back, I just want my client to issue the request and move on. I thought about kicking off another thread, issuing the request in the new thread, and then externally killing the thread but I'm not sure if this is even possible and even if it is, I don't think it would be very clean to forcibly kill the thread so I'm hoping there's s开发者_C百科omething more elegant.


Start another thread. You don't need to kill it, once request is done it will just exit. Use threadpool if you have too many of those requests.


Apache Mina is a networking library atop of Java NIO. Here are some async http request code snippets, using Mina, HttpClient, NIO, etc: http://code.google.com/p/async-future/wiki/Examples

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜