synchronized 并发问题

public static synchronized String getsmallcode(Object shop_id) {

        

        int maxsmallcode;

    String small_code = null;

        Orders orders = Orders.dao.findFirst("select MAX(small_code) as small_code from db_orders where shop_id=? and small_code!='' and date(create_date) = curdate()", shop_id);

small_code = orders.get("small_code");

if (StrKit.isBlank(small_code)){

maxsmallcode = 100;

return String.valueOf(maxsmallcode);

}

maxsmallcode = Integer.parseInt(small_code);

maxsmallcode++;

return  String.valueOf(maxsmallcode);

        

}

排队怎么不管用啊!

评论区

热门反馈

扫码入社