a way of method hook like java shutdown-hook