What happens in the following case?
Timer t = new Timer();
t.schedule(...);
t = new Timer();
Specifically, what happens to the the tasks that I’ve scheduled on Timer t after I’ve assigned a new instance of Timer to t?
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.
They doesn’t go away. Each
Timerobject is associated with a background process. Even when you remove all references to yourTimerin your program, the background process will still continue to run (it holds it’s own reference to the object). Because of this, the object will not be subject to garbage collection.See the official documentation for details.