Timer for the Java Timer task

Source: Internet
Author: User

These days have been engaged in an early warning monitoring daemon, the other is done, the most tangled is that the daily fixed time to execute the problem, the main reason for the tangle is not clear the method of the timer, Timer.schedule (timertask task,long l1,long L2 ), it is clear that the task is executed after the L1 time period and then executed once per L2 time,

But Timer.schedule (timertask task,date l1,long L2), just started not to be too clear, always thought is L1 of the Date control of the daily execution, ignoring the existence of L2, always on the Date on the top of the mess, just started to want to press

Timer.schedule (timertask task,long l1,long L2), the logic to achieve a daily execution, but somehow changed direction, leading to confusion for a long time, and then suddenly found that this timer.schedule ( TimerTask task,date L1,long L2); and Timer.schedule (timertask task,long l1,long L2); it's exactly the same, just different types, are based on the value of L2 to determine the number of runs and frequency, but the former is a fixed time for the first run, and the latter is the number of milliseconds after the first run time, so a small understanding of the error, resulting in my day more time wasted, did a lot of useless! Alas! Be sure to pay attention to this mistake next time! Can't stumble on the same rock for the second time!

Also hope that children's shoes in the study work, must not take a similar detour, too wasted time!

Timer for the Java Timer task

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.