Java 11 migration: patterns (t-v) (#1085)
* Moves visitor pattern to java 11 * Moves value-object pattern to java 11 * Moves unit-of-work pattern to java 11 * Moves typeobjectpattern pattern to java 11 * Moves twin pattern to java 11 * Moves trampoline pattern to java 11 * Moves tolerant-reader pattern to java 11 * Moves tls pattern to java 11 * Moves throttling pattern to java 11 * Moves thread-pool pattern to java 11 * Moves template-method pattern to java 11
This commit is contained in:
committed by
Ilkka Seppälä
parent
160b737dcc
commit
50467c9e76
@ -26,6 +26,7 @@ package com.iluwatar.throttling;
|
||||
import com.iluwatar.throttling.timer.ThrottleTimerImpl;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.IntStream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -73,14 +74,14 @@ public class App {
|
||||
private static void makeServiceCalls(Tenant tenant, CallsCount callsCount) {
|
||||
var timer = new ThrottleTimerImpl(10, callsCount);
|
||||
var service = new B2BService(timer, callsCount);
|
||||
for (int i = 0; i < 20; i++) {
|
||||
// Sleep is introduced to keep the output in check and easy to view and analyze the results.
|
||||
IntStream.range(0, 20).forEach(i -> {
|
||||
service.dummyCustomerApi(tenant);
|
||||
// Sleep is introduced to keep the output in check and easy to view and analyze the results.
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.error("Thread interrupted: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +73,6 @@ public final class CallsCount {
|
||||
*/
|
||||
public void reset() {
|
||||
LOGGER.debug("Resetting the map.");
|
||||
for (Entry<String, AtomicLong> e : tenantCallsCount.entrySet()) {
|
||||
tenantCallsCount.put(e.getKey(), new AtomicLong(0));
|
||||
}
|
||||
tenantCallsCount.replaceAll((k, v) -> new AtomicLong(0));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user