同步方法
- 创建一个service
@Component
public class AsyncService {
public void test1(){
//打印线程name
System.out.println("test1 start:" + Thread.currentThread().getName());
//模拟程序执行
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("test1 end");
}
public void test2(){
System.out.println("test2 start:" + Thread.currentThread().getName(