package com.zy.core; import com.zy.core.properties.SystemProperties; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.annotation.PreDestroy; /** * WCS主流程 * Created by vincent on 2020/8/6 */ @Data @Slf4j @Component public class MainProcess { // 所属线程 private Thread thread; /** * =====>> 开始工作 */ public void start(){ thread = new Thread(() -> { while (!Thread.currentThread().isInterrupted()) { try { // 系统运行状态判断 if (SystemProperties.WCS_RUNNING_STATUS.get()) { continue; } // 间隔 Thread.sleep(1500); log.info("WCS 工作中 ....................."); } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); } @PreDestroy public void shutDown(){ if (thread != null) thread.interrupt(); } }