Thursday, October 4, 2012

Executing a task at a particular time interval using Schedular

public void startSchedular()
    {
        Scheduler scheduler = null;
        try
        {
String schedularTime=30 * * * 1-7//This will run after every 30 minutes for all 7 days
            scheduler = new Scheduler();
            scheduler.schedule(schedularTime, new Runnable()
            {
                @Override
                public void run()
                {
                    readEmails();
                }
            });
            scheduler.start();
        } catch (Exception e)
        {
            e.printStackTrace();// TODO: handle exception
            scheduler.stop();
        }
    }


To work with schedular download cron4j.jar
Schedular Patterns example

For More details Click here

No comments:

Post a Comment

Spring Boot Config Server and Config Client.

 In Spring cloud config we can externalise our configuration files to some repository like GIT HUT, Amazon S3 etc. Benefit of externalising ...