Java – call thread What kind of corruption may occur when the stop method is used?
See the English answer > thread Stop () – deprecated 4
I just don't quite understand What does an inconsistent state mean?
What can arbitrary behavior be? Can someone explain to me?
(my question is slightly different from the repeated question you think. I emphasize possible damage, while the former emphasizes what method can be used to replace thread. Stop.)
Solution
Consider any type of complex data structure, such as double linked list Thread lock structure, view and change it, and then release the lock So consider:
>Lock list. > Adjust the forward pointer. > Adjust the corresponding reverse pointer. > Unlock
Imagine if a thread has completed steps 1 and 2, then you stop it The bidirectional linked list is invalid because it is half modified If another thread acquires this lock and tries to traverse the list, it will lead to disaster