From 12e9ce64c364deb7ea08ba82f8d72abf6e561fc2 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期一, 27 五月 2024 16:53:50 +0800
Subject: [PATCH] 田间灌溉项目管理 灌溉制度模块 修改查询流浪灌溉单元和已绑定灌溉单元接口返回id类型 作物分页查询增加返回备注字段
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java | 95 +++++++++++++++++++----------------------------
1 files changed, 38 insertions(+), 57 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java
index 0d41ea4..8e497f2 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/core/CoreConstantThread.java
@@ -1,64 +1,45 @@
package com.dy.common.mw.core;
-import java.util.List;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.*;
+/**
+ * @Author liurunyu
+ * @Date 2023/12/19 16:41
+ * @LastEditTime 2023/12/19 16:41
+ * @Description
+ */
+public class CoreConstantThread extends Thread {
-public class CoreConstantThread extends Thread{
-
- private final static Logger log = LogManager.getLogger(CoreConstantThread.class.getName()) ;
-
- private final static CoreConstantThread instance = new CoreConstantThread() ;
+ private final static Logger log = LogManager.getLogger(CoreConstantThread.class.getName()) ;
- @SuppressWarnings("unused")
- private static Long sleepBigBusy = 100L ;//澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
- private static Long sleepSmallBusy = 500L ;//灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
-
- private CoreConstantThread(){
- }
-
- public static CoreConstantThread getInstance(){
- return instance ;
- }
-
- /**
- * 璁剧疆鏆傚仠鏃堕暱
- * @param sleepBigBusy 澶у繖鏃讹紙闄や簡鎭掍箙浠诲姟锛岃繕鏄叾浠栦换鍔★級锛屾牳蹇冪嚎绋嬫殏鍋滈棿闅�
- * @param sleepSmallBusy 灏忓繖鏃讹紙鍙湁鎭掍箙浠诲姟锛屾棤鍏朵粬浠诲姟锛夛紝鏍稿績绾跨▼鏆傚仠闂撮殧
- */
- public void setSleep(Long sleepBigBusy, Long sleepSmallBusy){
- CoreConstantThread.sleepBigBusy = sleepBigBusy ;
- CoreConstantThread.sleepSmallBusy = sleepSmallBusy ;
- }
+ private long sleepBigBusy ;
+ private long sleepSmallBusy ;
+ private CoreTask task ;
- /**
- * 鏍稿績鍗曠嚎绋嬶紝鎵ц鎵�鏈夌殑鍗曠嚎绋嬩换鍔�
- */
- @Override
- @SuppressWarnings("InfiniteLoopStatement")
- public void run(){
- int count ;
- Integer temp ;
- while (true) {
- count = 0;
- try {
- //鎭掍箙浠诲姟
- List<CoreTask> constantTasks = CoreUnit.getAllConstantTasks();
- if (constantTasks != null && constantTasks.size() > 0) {
- for (CoreTask task : constantTasks) {
- temp = task.execute();
- if (temp != null) {
- count += temp;
- }
- }
- }
- if (count == 0) {
- //灏忔殏鍋滀竴涓�
- Thread.sleep(sleepSmallBusy);
- }
- } catch (Exception e) {
- log.error("鏍稿績绾跨▼鍙戠敓寮傚父" + (e.getMessage() == null ? "" : (":" + e.getMessage())), e);
- }
- }
- }
+ public CoreConstantThread(long sleepBigBusy, long sleepSmallBusy, CoreTask task){
+ this.sleepBigBusy = sleepBigBusy ;
+ this.sleepSmallBusy = sleepSmallBusy ;
+ this.task = task ;
+ }
+
+ @Override
+ public void run() {
+ if(task != null){
+ int count ;
+ while (true) {
+ try {
+ count = task.execute();
+ if (count == 0) {
+ //灏忔殏鍋滀竴涓�
+ Thread.sleep(sleepBigBusy);
+ }else{
+ Thread.sleep(sleepSmallBusy);
+ }
+ } catch (Exception e) {
+ log.error("鎭掍箙浠诲姟" + task.getClass().getName() + "鎵ц鏃跺彂鐢熷紓甯�" + (e.getMessage() == null ? "" : (":" + e.getMessage())), e);
+ }
+ }
+ }
+ }
}
--
Gitblit v1.8.0