Is the ObjectInputStream.readObject () timeout set?

I have ObjectInputStreamconnected to ObjectOutputStreamthrough a socket, and I used Socket.setSoTimeout()to make ObjectInputStream.readObject()only a 100 ms block. Since I started to do this, I got a lot StreamCorruptedErroron call readObject(). Can the time limit be to blame?

+3
source share
2 answers

I have a thread constantly receiving new data using this function, but I want to stop it by setting boolean to false. The stream must support boolean polling and cannot, if blocked by readObject ()

Thread.interrupt, InterruptedException, InterruptedIOException. , !

+5

- , , , , , - .

100 , . - , .

+3

Source: https://habr.com/ru/post/1791597/