java 函数独占锁
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@RestController
@RequiredArgsConstructor
@RequestMapping("/smartpark" )
@Tag(description = "开放接口", name = "开放接口")
//@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class SmartParkController {
@Autowired
private CustomSqlService customSqlService;
private Lock accountLock = new ReentrantLock();
@Operation(summary = "数字接口", description = "数字接口")
@GetMapping("/synchrodataByGarden1/{id}")
@Inner(false)
public Map<String,Object> synchrodataByGarden1(@PathVariable("id") String strYear){
accountLock.lock();
Map<String, Object> mResult = new HashMap<>();
try {
//过程
}catch (Exception ex){
mResult.put("接口异常",ex.toString());
}finally {
accountLock.unlock();
return mResult;
}
}
}
择善人而交,择善书而读,择善言而听,择善行而从。