wang
2024-03-26 ea073afc6b4bc758990ac60f5e33254d1143272c
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
package com.mes.service;
 
import com.mes.entity.DownGlassInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
 
@Component
public class ThreadExample implements ApplicationRunner {
 
  @Autowired
  private DownGlassInfoService downGlassInfoService;
 
  @Override
  public void run(ApplicationArguments args) throws Exception {
    Thread thread = new Thread(() -> {
      DownGlassInfo downGlassInfo = downGlassInfoService.getDownGlassInfoById(1); // 设置需要查询的id
      System.out.println("Down Glass Info in new thread: " + downGlassInfo);
    });
    thread.start();
  }
 
 
}