在orderProductMockDiffUser(String productId)方法体上加入synchronized关键字,可以保证每次都是单线程处理,
因为加上了锁。但这种做法只适合单点操作,即单机上的做法,对于多机上来说的话是不合适的。
package com.imooc.controller;
import com.imooc.service.SecKillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/skill")
@Slf4j
public class SecKillController {
@Autowired
private SecKillService secKillService;
/**
* 查询秒杀活动特价商品的信息