We have all read about finalizers and the reasons why you shouldn't use it within your program.
However, I have a good way of making use of them.
If you have resources that need to be freed within your
main program *hint* *hint*, then why not use finalizers in that one place?
It isn't going to do anything bad. Java will have to handle all the horrible exceptions and internal mess afterwards and not in the program.
BTW: I realise this isn't how you properly terminate threads.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| class Main extends JFrame { .....................
public static void main(String[] elephants){ ..................... }
...........
protected void finalize() throws Throwable { super.finalize(); tmpThread.interrupt(); tmpThread = null; }
................ } |