How to stop a thread waiting in a blocking read operation in Java?

后端 未结 7 1918
萌比男神i
萌比男神i 2020-12-03 10:40

I have a thread that executes the following code:

public void run() {
    try {
        int n = 0;
        byte[] buffer = new byte[4096];
        while ((n          


        
7条回答
  •  醉话见心
    2020-12-03 11:08

    Is it safe to close in stream in other thread? It works for me. In this case, in.read(...) throws exception SocketException.

提交回复
热议问题