java - ExecutorService schedule single task only -


I am working on a bot that does some stuff at specified change intervals. The user of the application, whenever he works in the GUI, has the option to do the stuff. Although it is said that the main function then calculates the remaining time until the next item should not be made and it passes the scheduler. In addition, the application should be capable of running very long.

  Public Ultimate Class Bot {Private Scheduled Future   

(While writing this, I was under the assumption that mainHandle will only schedule the latest work - but this is my first time with scheduling. . And I am amazed.)

The code works, but every time when the is called the main function () , a new task is created on the top of the previous work ( Usually with the same delay)). This app is unwanted by the user to work with every manual call () , I just want to keep "the latest" and want to discard the old ones.

What would be the best solution to my problem?

I would like to keep the solution as simple as possible without the use of frameworks.

To respond to your title: use submit Use the schedule , or any related function. Specially look at the Executor Service interface instead of Scheduled Exclaration Service , as there will be no revision in its methods.

To answer that which I think is your real question:

I only want to keep "the latest" work and want to discard the big ones.

Note that when you schedule a task scheduled future & lt ;? & Gt; is back you can cancel it when new job is submitted.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -