2013年9月13日星期五

Spring + quartz timer called twice initial implementation tasks , how to solve ?

Recently wrote a timer task , service starts, performed twice , after which the normal , such as: 10 seconds called once System.out.println (new Date ()), the first execution is to print two exactly the same time , after every 10 seconds to print once. Trouble to help solve what, how to make the first call to execute only once ?
ps: Baidu , and there are users that tomcat configuration change , stressing profile to be loaded separately , have tried , no problem ~ ~

trouble you , urgently ~ ~ ~
------ Solution ---------------------------- ----------------
possible, the source code stickers !
------ For reference only -------------------------------------- -
not find a good way to temporarily write flag , the first execution of judgment , then do not perform , the second started. Expect good way ~
------ For reference only --------------------------------- ------
Hello , I also encountered the same problem. I am not a tomcat startup . I was directly in the main method in the boot .
But I sometimes normal , perform a second . Sometimes perform several times ? If the component scanning instantiated multiple times. You should always perform a few ah. I am using the cron expression 0 / 10 ** ? *** 10 seconds once. Quartz per minute at 10 seconds, 20 seconds, 30 seconds , 40,50,00 , started. I'm the wrong time are generally less than the whole second time . In other words . May be 15 seconds , 18 seconds so that the time . Execution times. Until the entire second when it began operating normally.

------ For reference only ---------------------------------- -----
# 3 you are not integrated spring up ? ?

没有评论:

发表评论