Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

Rescheduling a job scheduled with scheduledExecutorService

Hi,
In my spring mvc application. I am scheduling a job using scheduledExecutorService.
here is code :
ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(5);
            SimpleJob simpleJob = new SimpleJob(guid);
            ScheduledFuture scheduledFuture = scheduledExecutorService.schedule(simpleJob,
                    Calendar.getInstance().getTimeInMillis() - calendar.getTimeInMillis()
                    , TimeUnit.MILLISECONDS);
        }

Open in new window


Take for example that above a job is scheduled after 1000000 milliseconds.
Now it may happen that my web application gets a http request saying that reschdule the job for some guid to 2000 milliseconds.
guid is a string i am passing above in the job which identifies a particular job.

Now if the job is already running or has run... i can ignore the request of recheduling.
But suppose it has yet to run.. In that case i want to rechdule it...

How to do it ?

Thanks
SOLUTION
Avatar of Moussa Mokhtari
Moussa Mokhtari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial