What happens when you call `Thread.stop()` in Java?
`Thread.stop()` immediately terminates the thread, halting its execution and releasing any resources it holds.
Thatâ€™s incorrect. `Thread.stop()` is unsafe and deprecated because it can leave resources in an inconsistent state. You should use other means like `interrupt()` or a flag.
Can you explain the risks of using `Thread.stop()` and how you should safely stop a thread?