Detailed explanation of the differences between timer’s schedule and scheduleatfixedrate methods in Java
Timer's schedule and scheduleatfixedrate methods are generally no different, but only when a certain situation occurs - the current task is handed over to the next task before it can be completed in time.
Let's take an example:
When the summer vacation comes, the teacher assigns homework to schedule and scheduleatfixedrate.
The teacher asked the students to write two pages a day in the summer vacation and finish their homework in 30 days.
The two students finished their homework on time every day until the 10th day. There was an accident. The two students spent five days traveling. Neither of them did their homework in these five days. The task was delayed.
At this time, the strategies adopted by the two students are different:
The schedule rescheduled the task. The first day after the trip, I did the task on the 11th day, the second day on the 12th day, and finally completed the task in 35 days.
Scheduleatfixedrate is a punctual student. She always wants to complete the teacher's tasks on time, so she completes all the tasks owed in the previous 5 days and the tasks on the 16th day on the first day of travel. Then she completes her homework according to the original arrangement of the teacher, and finally it takes 30 days to complete the task.
I hope I can help you!
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.