java - How to control same thread interference in application? -



java - How to control same thread interference in application? -

hi friend, facing critical issue current developing. using quartz library schedule tasks in application. , have prepare specific time phone call specific method. time , if method takes more execution time fixed time method beingness called 1 time again processing execute repeatedly. have tried synchronized keyword not working.

i using code schedule task -

import org.quartz.jobdetail; import org.quartz.scheduler; import org.quartz.schedulerexception; import org.quartz.trigger; import org.quartz.impl.stdschedulerfactory; import static org.quartz.jobbuilder.*; import static org.quartz.simpleschedulebuilder.*; import static org.quartz.triggerbuilder.*; public class brainscheluder { public brainscheluder() { seek { // grab scheduler instance mill scheduler scheduler = stdschedulerfactory.getdefaultscheduler(); // start scheduler here scheduler.start(); // define job , tie our brainjob class jobdetail job = newjob(brainjob.class) .withidentity("job1", "group1") .build(); // trigger job run now, , repeat every 60 seconds trigger trigger = newtrigger() .withidentity("trigger1", "group1") .startnow() .withschedule(simpleschedule() .withintervalinseconds(30) .repeatforever()) .build(); // tell quartz schedule job using our trigger scheduler.schedulejob(job, trigger); // end scheduler here //scheduler.shutdown(); } grab (schedulerexception se) { se.printstacktrace(); } } }

and using code perform work -

import java.util.linkedhashmap; import org.quartz.job; import org.quartz.jobexecutioncontext; import org.quartz.jobexecutionexception; import com.my.vi; public class brainjob implements job { vi v = null; public brainjob() { v= new vi(); } public synchronized void execute(jobexecutioncontext context) throws jobexecutionexception { v.mywork(); } }

the method of mywork of vi class used process info whenever info big size function beingness called repeatedly. , whenever info not big size function beingness called nicely.

so

can command mywork() method calling according our processing time requirement. mean can synchronized mywork() method ? here.

please help me. thanks

if understood well, set flag somewhere when mywork() starts (session, or context of sort, database, depends on other things using), , before each execution check status of flag. if method has not finished work, don't start again. 1 time finishes, reset flag, , when next scheduled time comes execute should.

java multithreading synchronization quartz-scheduler

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -