update list&tree

This commit is contained in:
ranwenjie
2021-12-22 17:12:08 +08:00
parent 3cc2b2da12
commit 667624355c
10 changed files with 212 additions and 51 deletions
+32
View File
@@ -5,3 +5,35 @@
```Java
static AtomicInteger qpsCount = 100; //线程安全
static volatile long lastSenconds = System.currentTimeMillis()/1000;
//1 计数器
public static boolean tryAcquire() {
long current = System.currentTimeMillis()/1000;
if(current == lastSenconds){
if (qpsCount-- > 0) {//CAS api
return true;
} else {
//限流
return false;
}
} else{//下一个时间窗口
lastSenconds = current;
qpsCount = 100;
return true;
}
}
```
-1
View File
@@ -18,7 +18,6 @@
数据结构
```