严智鑫
2024-03-06 f7ecb62a4fcfc86893458f1298995692315ff79f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.mes.service;
 
import com.mes.entity.DownGlassInfo;
 
import java.util.Collections;
import java.util.List;
 
public class Plcaction extends Thread {
 
  private static DownGlassInfoService downGlassInfoService; // 静态变量
 
  public static void setDownGlassInfoService(DownGlassInfoService service) {
    downGlassInfoService = service;
  }
 
  private List<DownGlassInfo> downGlassInfo; //
  private int i =1; //
  @Override
  public void run() {
    while (!Thread.currentThread().isInterrupted()) {
      try {
        i++;
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        e.printStackTrace();
      }
 
 
 
      downGlassInfo  = Collections.singletonList(downGlassInfoService.getDownGlassInfoById(1)); // 设置需要查询的id
   System.out.println("Down Glass Info in new thread: "+i + downGlassInfo);
    }
  }
}