I want Java Timer to call function n times after every t seconds. I am trying this right now it calls function after every t seconds but I want this function to be called for only n times.
Timer tt = new Timer();
tt.schedule(new MyTimer(url), 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.
I think
Timerdoesn’t have it as a built-in function. You will need to add a counter to count it for each call and then stop the timer usingcancel()after n times.Something like this: