4 ms·
This is a minor inaccuracy in Julia's post, Thread.stop() is deprecated, but it has not been disabled or removed: https://docs.oracle.com/en%2Fjava%2Fjavase%2F1
by hyperpape 2y ago
This is a minor inaccuracy in Julia's post, Thread.stop() is deprecated, but it has not been disabled or removed: https://docs.oracle.com/en%2Fjava%2Fjavase%2F17%2Fdocs%2Fapi%2F%2F/java.base/java/lang/Thread.html#stop https://docs.oracle.com/en%2Fjava%2Fjavase%2F17%2Fdocs%2Fapi...().
InterruptedException is better, but requires something closer to cooperative multi-tasking. If the thread is in a long-running loop that's not doing IO or it swallows the InterruptedException, you won't actually be able to kill the thread.
At work, someone had implemented an interface that let you kill a thread prior to my joining the company, so I found out that the warnings are very real when someone did that and it left the application unable to fetch DB connections.
- philipwhiuk 2y agoThreadGroup.stop() was removed in 23, so maybe in the future it'll actually be removed.