@Schedule 开始两次

@Schedule starts twice

这个程序每天凌晨4点开始,但是每天的schedule都开始两次,我已经检查过任何一个周期,但一切都井井有条。 为什么它总是启动两次? 我该如何解决?

import javax.ejb.LocalBean;
import javax.ejb.Schedule;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

@Stateless
@LocalBean
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class RichiamiSync {
    @Schedule (minute = "00", hour = "04")

    public  void main() {

        try {
            Logica.esegui();
            }
            catch (Exception e) {
                Log.write("ERROR  " + e);
                Log.write("---------------------ERRORE FATALE IL PROGRAMMA E' STATO ARRESTATO-------------------------");   
                }
        Ottimizza.sql();

        Log.sendEmail();


    }




}

最初这些方法是这样记录的:

@Singleton
@LocalBean
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

但是在另一个问题中他们说使用无状态就可以解决,现在问题总是一样

这是解决方案:

@Singleton
@LocalBean
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public class ServerStartStop {

    private ExecutorService es2 = Executors.newSingleThreadExecutor();
    private Future<Void> operazioniAggiornamentoUI =null;
    
    
    @Schedule(hour = "*" ,minute = "*",second = "*/10", persistent = false)
    public void AggiornamentoUI(Timer timerInfo) {
        
        if (operazioniAggiornamentoUI!=null)
            if(!operazioniAggiornamentoUI.isDone())
                return;
        
        
        Callable<Void> callableObj = () -> { try {

            GestoreAcquisizioneOrdiniUI.aggiornaUiAcquisizioneOrdini();
            
            
            
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
        };
        
        
        
        operazioniAggiornamentoUI=es2.submit(callableObj);
        
        
        
        
    }}