|
|
@ -26,7 +26,7 @@ public class RunStateHandlerTest {
|
|
|
|
// @PostConstruct
|
|
|
|
// @PostConstruct
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
@SuppressWarnings("all")
|
|
|
|
public void runStateHandlerTest() {
|
|
|
|
public void runStateHandlerTest() {
|
|
|
|
log.info("测试线程池运行时状态接口, 30s 后开始触发拒绝策略...");
|
|
|
|
log.info("Test thread pool runtime state interface, The rejection policy will be triggered after 30s...");
|
|
|
|
|
|
|
|
|
|
|
|
ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor();
|
|
|
|
ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor();
|
|
|
|
scheduledThreadPool.scheduleAtFixedRate(() -> {
|
|
|
|
scheduledThreadPool.scheduleAtFixedRate(() -> {
|
|
|
@ -34,12 +34,12 @@ public class RunStateHandlerTest {
|
|
|
|
ThreadPoolExecutor pool = executorService.getPool();
|
|
|
|
ThreadPoolExecutor pool = executorService.getPool();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
pool.execute(() -> {
|
|
|
|
pool.execute(() -> {
|
|
|
|
log.info("线程池名称 :: {}, 正在执行即将进入阻塞...", Thread.currentThread().getName());
|
|
|
|
log.info("Thread pool name :: {}, Executing incoming blocking...", Thread.currentThread().getName());
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
int maxRandom = 10;
|
|
|
|
int maxRandom = 10;
|
|
|
|
int temp = 2;
|
|
|
|
int temp = 2;
|
|
|
|
Random random = new Random();
|
|
|
|
Random random = new Random();
|
|
|
|
// 这里为了赋值线程池 completedTaskCount
|
|
|
|
// Assignment thread pool completedTaskCount
|
|
|
|
if (random.nextInt(maxRandom) % temp == 0) {
|
|
|
|
if (random.nextInt(maxRandom) % temp == 0) {
|
|
|
|
Thread.sleep(10241024);
|
|
|
|
Thread.sleep(10241024);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -55,4 +55,5 @@ public class RunStateHandlerTest {
|
|
|
|
|
|
|
|
|
|
|
|
}, 5, 2, TimeUnit.SECONDS);
|
|
|
|
}, 5, 2, TimeUnit.SECONDS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|