What happens to a BufferedReader that doesn't get closed within a callable.call?

后端 未结 5 733
后悔当初
后悔当初 2021-02-04 14:47

I have three questions.

To explain, I was reviewing someone\'s code, and noticed BufferedReaders sometimes aren\'t being closed. Usually, Eclipse gives a w

5条回答
  •  粉色の甜心
    2021-02-04 15:16

    1. Doesn't highlight and it's true, because a stream can be closed somewhere else out of the call method.

    2. If it's closed within the call method that other threads may be using it at the moment.

    3. With the BufferdRreader nothing but if you loose the reference to stream and cannot close it and this leads to a memory leak.

提交回复
热议问题