private List synchedList = Collections.synchronizedList(new LinkedList());
@GetMapping("/test1")
public String test1(){
synchronized (synchedList) {
try {
System.out.println("test1");
synchedList.wait();
System.out.println("test1:结束");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return "test1等待test2执行完";
}
@GetMapping("/test2")
public String test2(){
synchronized (synchedList) {
synchedList.notifyAll();
System.out.println("test2");
return "test2";
}
}
09-10