有什么办法,我可以得到一个线程安全缓冲的读者。我得到了以下信息,当我跑这个代码#缓冲读写器线程安全吗?
Threadid=28 [email protected]
Threadid=28 [email protected]
Threadid=28 [email protected]
Threadid=28 [email protected]
28 started Reading
Threadid=28 [email protected]
Threadid=28 [email protected]
Threadid=28 [email protected]
Threadid=28 [email protected]
28 finished Reading
Threadid=38 [email protected]
Threadid=38 [email protected]
Threadid=38 [email protected]
Threadid=38 [email protected]
38 started Reading
Threadid=38 [email protected]
Threadid=38 [email protected]
Threadid=38 [email protected]
Threadid=38 [email protected]
38 finished Reading
的缓冲读者的哈希码,InputStreamReader和InputStream中仍然same.Why?
种类略过细节,但不能只是创建一个线程安全包装类? – mre
我认为如果InputStream是相同的,BufferedReader的哈希码可能是相同的。你也可以尝试解释一下情况好一点吗?很难制定出合适的答案。 – TFennis
'reader'等是静态还是局部变量?你如何创建输出?哈希码应该改变每个新的对象和AFAIK使用一个构造函数,没有办法可以创建一个已经存在的对象(除非在一些本地代码中发生这种情况,但是我怀疑'BufferedReader'等情况)。 – Thomas