HtmlUnit WebClient Timeout

三世轮回 提交于 2019-12-04 14:42:59

Future.cancel(boolean) returns:

  • false if the task could not be cancelled, typically because it has already completed normally
  • true otherwise

Cancelled means means the thread did not finish before cancel, the canceled flag was set to true and if requested the thread was interrupted.

Interrupt the thread menans it called Thread.interrupt and nothing more. Future.cancel(boolean) does not check if the thread actually stopped.

So it is right that cancel return true on that cases.

Interrupting a thread means it should stop as soon as possible but it is not enforced. You can try to make it stop/fail closing a resource it needs or something. I usually do that with a thread reading (waiting incoming data) from a socket. I close the socket so it stops waiting.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!