timer - scheduling runnable tasks in java -


I'm following an interesting point on the use of scheduled Tahradpool Explorer for some repetitive tasks.

Scheduling this object returns a scheduled return futures object that can be used to cancel the next run of the task.

One thing to note is that the work itself is completely decrypted from the schedule -

  scheduled exclosure service executor = new Scheduled Thread Paul Exchanger (1); ScheduledFuture nextSchedule = Examiner Schedule (work, 60000, time unit. Milliseconds);  

Where -

  Some Task Functions = New Tasks ();  

So the work itself is not aware of the schedule if there is any way to cancel the job and create a new schedule for yourself, please understand.

Thank you

There is no such reason that this work is done by scheduled exhaupors Service can not reference and schedule yourself to run again if necessary: ​​

  // (need to create last variable * if * this is a Local (method) variable.) Last Scheduled Exclor Service execService = Exporter. NewSingleThreadScheduledExecutor (); // Make usable callable again in cases where there are states of callable us. Based on the requirements, each time a new instance may be required to repay & LT; Zero & gt; Work = new callable () {public zero call () {try do doProcessing (); } Finally, the same function to run the {// schedule (even if processing fails) ExecService.schedule (this, 1, time unit. SECONDS); }}}  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -