Description
Provide a ThreadPool that can allow only specific number of cars to get through at once.
ExecutorService
Scenario
The traffic is pretty bad and crowded, only limited number cars can get through
Given 2 parameters for method A(int allowCars, int totalCars)
And one AtomicInteger variable(B) to increase/decrease the number of cars
And one variable maxCars(C) to record the max(B)
When allowCars = 2, and totalCars = 10
Expect maxCars = 2
When allowCars = 3, and totalCars = 20
Expect maxCars = 3
When allowCars = 1, and totalCars = 1
Expect maxCars = 1
Additional context
Add any other context, links references or screenshots about the feature request here.
Important Checklist