I am currently learning the Web in Java and as the first project I am doing an online auction. After writing all the CRUD operations, I faced the task “how to check the end of the auction of the lot” and then I got stuck.

Actually, in the “DB”, the lot has two fields: startDate and finishDate - my idea is that after launching the application, some event schedule object starts, which takes the end date of the lot and checks with the current date, and depending on this, changes the state of the lot . If someone has done something similar, tell me which way to look, so that the application does not slow down as a result of such checks or you may have a link where this problem is implemented.

    1 answer 1

    I can offer several options:

    1. The most commonplace, run the background thread, which will check. This can be done using the ScheduledExecutorService
    2. Using a third-party quartz library
    3. If you are using spring that is, an option, use the @Scheduled annotation to select a method that will be executed with a specified frequency
    4. I recommend also to look at a project like spring batch for batch processing.