Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
How to correctly prevent that an application is runned again untill a previous instance ends using lock file?

I am working on a simple Spring console application (it is a litle batch working on a database).

This batch is scheduled to start at specific time. The problem is that the execution of this program can take a lot of time and the scheduler can try to start it before the previous instance of this program completed its work.

So I think that I can use a lock file to handle this situation, my idea is:

  • When the batch start it check if there is this lock file in its folder (if this lock file is present, the batch application ends without doing anything).
  • If the lock file can't be found: create the lock file and start the batch operations.

Do you think that it could be a valid approach to the problem? Or Spring provide some smarter way?

Another doubt is: what is the standard for a lock file? Can I create simply a .lock file in the current folder?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda