Open Zimang opened 7 months ago
The problem with the code is that it doesn't check if the thread has been interrupted. If the thread is interrupted, the interrupted
method returns true, and the loop should exit. But the code checks if the thread has been interrupted, and if it has, the loop should continue. This is a typo, and the correct code should be:
while (!Thread.currentThread().interrupted()) {
This code checks if the thread has been interrupted, and if it has, the loop exits.
Other chapter examples have similar logic(For Ex - chapter four NewsWriter,java in NewsReader), so this is probably just a typo.
source code has a problem in the while, which makes it dosen't log. It should be