How to interrupt BufferedReader's readLine

后端 未结 9 1397
醉梦人生
醉梦人生 2020-11-29 07:56

I am trying to read input from a socket line by line in multiple threads. How can I interrupt readLine() so that I can gracefully stop the thread that it\'s bl

9条回答
  •  旧巷少年郎
    2020-11-29 08:46

    you can design a Timer class around the read() block.

    you need to set a timeout for your timer.

    on timeout just interrupt your thread.

提交回复
热议问题