What is the difference between stopping a java Thread and stopping an instance of Timer ?
Why is timer.cancel thread safe or is it ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Cancelling a timer doesn’t have any of the potentially destabilizing behaviour of aborting a thread. From the docs:
In other words, it’s not going to try to stop a task which is already running, which could potentially end up with monitors not being released etc. It’s just going to avoid running any more tasks.