您的位置:首页 > 其它

定时任务配置

2015-09-24 18:00 323 查看
<bean id="cronTriggerPay" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="schedule.PushJob"></property>
</bean>
</property>
<property name="cronExpression" value="0-59/1 * * * * ? *" />
</bean>
<!-- 执行实际的调度 -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="cronTriggerPay"></ref>
</list>
</property>
</bean>

if (!isRunning)

        {

            System.out.println(new Date() + "------>定时任务开始");

            isRunning = true;

            for (int i = 1; i <= 100; i++)

            {

                System.out.println("作业完成:" + i);

                try

                {

                    Thread.sleep(1000);

                }

                catch (InterruptedException e)

                {

                    e.printStackTrace();

                }

                

            }

            System.out.println(new Date() + "------>定时任务结束");

            

        }

        else

        {

            System.out.println(new Date() + " 任务结束!");

            isRunning = false;

        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: