目录
一、@EnableAsync
二、@Async
三、测试
一、@EnableAsync

二、@Async

@Service
public class IotLocationServiceImpl {
    @Async
    public void testA() {
        try {
            // 模拟阻塞
            Thread.sleep(5000);
            System.out.println("子线程执行完毕");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}三、测试
@Slf4j
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {
    private final IotLocationServiceImpl iotLocationService;
    @PostMapping("/test")
    public Result<?> test() {
        iotLocationService.testA();
        return Result.success();
    }
}









![[数据结构 -- 手撕排序第三篇] 冒泡排序](https://img-blog.csdnimg.cn/img_convert/014b664afcbcc36ea28344655f60ba30.png)









