-
启动类添加
@EnableAsync
注解 开启线程池(多线程) -
新增异步添加接口
package com.chalk.service;
import com.chalk.model.Student;
import com.chalk.model.Teacher;
import com.chalk.model.UserDeviceRel;
import java.util.List;
/**
* 异步服务接口
*
* @author gluoh
* @since 2020-12-14 19:29:01
*/
public interface AsyncService {
/*自定义接口*/
void asyncIssuedPerson(List<UserDeviceRel> issuedList);
}
异步添加接口实现
package com.chalk.service.impl;
/**
* 异步服务实现类
*
* @author gluoh
* @since 2020-12-21 16:32:10
*/
@Service
public class AsyncServiceImpl implements AsyncService {
@Autowired
private UserDeviceRelService userDeviceRelService;
@Async
@Override
public void asyncIssuedPerson(List<UserDeviceRel> issuedList) {
System.out.println(
Thread.currentThread().getName() +