我目前正在使用Java(春季启动)开发约会系统,但遇到了问题,
两(2)个用户几乎同时要求相同的时间时,我的验证不起作用
说明:
New request recieved
// Fetch all the previous request from the database and checks if there is any kind of conflicts
Verification();
// If no conflict found
saveAppointment();
示例:
用户1在11:03请求约会: 50 日期:2020/12/12 开始:10:00 结束:12:00
用户1在11:03请求约会: 51 日期:2020/12/12 开始:10:00 结束:12:00
问题: 系统会保存这两个文件,而不会发现任何问题,因为两者都同时发生,并且系统无法提取任何先前的约会。
有没有一种方法可以让系统在有请求进行时等待,而只有在第一个请求完成后才处理另一个请求?