1. Current limiting of the counter
package cn.gov.zcy.tender.pubfund; import org.springframework.stereotype.Component; @Component public class CounterLimit { private Long initTime=System.currentTimeMillis(); /** * Private Long Interval =60000L; private int reqCount=0; private int limit =100; public Boolean grant(){ Long now = System.currentTimeMillis(); if(now<initTime+interval){ reqCount++; return reqCount<limit; }else{ initTime=now; reqCount=1; return Boolean.TRUE; }}}Copy the code