File tree 1 file changed +11
-2
lines changed
src/main/java/io/api/etherscan/manager/impl
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import io .api .etherscan .manager .IQueueManager ;
4
4
5
- import java .util .concurrent .*;
5
+ import java .util .concurrent .Executors ;
6
+ import java .util .concurrent .ScheduledExecutorService ;
7
+ import java .util .concurrent .Semaphore ;
8
+ import java .util .concurrent .TimeUnit ;
6
9
7
10
/**
8
11
* Queue Semaphore implementation with size and reset time as params
@@ -54,7 +57,13 @@ public void takeTurn() {
54
57
}
55
58
56
59
private Runnable releaseLocks (int toRelease ) {
57
- return () -> semaphore .release (toRelease );
60
+ return () -> {
61
+ int availablePermits = semaphore .availablePermits ();
62
+ int neededPermits = toRelease - availablePermits ;
63
+ if (neededPermits > 0 ) {
64
+ semaphore .release (neededPermits );
65
+ }
66
+ };
58
67
}
59
68
60
69
@ Override
You can’t perform that action at this time.
0 commit comments