JVM provides you a hook to register a thread with the shutdown initiation sequence. Once a thread is registered, on every shutdown that thread is run.
Now, is there any such a hook java provide to register a thread with JVM's Garbage collector?
Not exactly a hook, but you can use a WeakReference to be notified that an object has become eligible to be garbage collected.