【发布时间】:2011-09-04 04:29:55
【问题描述】:
可能重复:
How to terminate a thread blocking on socket IO operation instantly?
我有客户端在线程中运行,想要从 Java 中的套接字读取。但是在阅读时,也许我想杀死线程。所以我interrupt它,但是socket的读取方法会抛出InterruptedException吗?没找到。
那么,我怎样才能很好地要求线程在读取套接字时阻塞?
谢谢
【问题讨论】:
-
Check this reference,它适用于 Reader 和 InputStream
标签: java multithreading sockets network-programming interrupted-exception