There is no difference, whether a shutdown hook Thread is daemon or not.
As the specification for Runtime.addShutdownHook
says,
When the virtual machine begins its shutdown sequence it will start
all registered shutdown hooks in some unspecified order and let them
run concurrently. When all the hooks have finished it will then run
all uninvoked finalizers if finalization-on-exit has been enabled.
Finally, the virtual machine will halt. Note that daemon threads will
continue to run during the shutdown sequence, as will non-daemon
threads if shutdown was initiated by invoking the exit method.
and
Once the shutdown sequence has begun it can be stopped only by
invoking the halt method
JDK implementation follows these rules. As we see in the source code, runHooks
starts hook threads and waits until all of them finish:
for (Thread hook : threads) {
hook.start();
}
for (Thread hook : threads) {
while (true) {
try {
hook.join();
break;
} catch (InterruptedException ignored) {
}
}
}