简体   繁体   中英

Connection timeout in java?

如果HttpURLConnection在完成之前超时,有什么方法可以触发事件?

There is no built-in timeout for this. What I do is to use a different thread and interrupt the thread after the timeout.

It's easier to use FutureTask for this. See my answer to this question,

java native Process timeout

URLConnection.setConnectTimeout()
URLConnection.setReadTimeout()

@since 1.5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM