648540858
2023-08-03 a01086fe1c0accccf8ee5f98e601a6b14f0cf152
src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.conf;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
@@ -100,7 +101,7 @@
    public boolean stop(String key) {
        boolean result = false;
        if (futureMap.get(key) != null && !futureMap.get(key).isCancelled() && !futureMap.get(key).isDone()) {
        if (!ObjectUtils.isEmpty(futureMap.get(key)) && !futureMap.get(key).isCancelled() && !futureMap.get(key).isDone()) {
            result = futureMap.get(key).cancel(false);
            futureMap.remove(key);
            runnableMap.remove(key);
@@ -127,11 +128,15 @@
    public void execute(){
        if (futureMap.size() > 0) {
            for (String key : futureMap.keySet()) {
                if (futureMap.get(key).isDone()) {
                if (futureMap.get(key).isDone() || futureMap.get(key).isCancelled()) {
                    futureMap.remove(key);
                    runnableMap.remove(key);
                }
            }
        }
    }
    public boolean isAlive(String key) {
        return futureMap.get(key) != null && !futureMap.get(key).isDone() && !futureMap.get(key).isCancelled();
    }
}