feature: 优化示例项目变量命名.

pull/10/head
chen.ma 3 years ago
parent 7bd785f76c
commit 3768d65a6e

@ -1,9 +1,9 @@
package com.github.dynamic.threadpool.example.config;
import com.github.dynamic.threadpool.starter.core.DynamicThreadPool;
import com.github.dynamic.threadpool.starter.toolkit.thread.CustomThreadPoolExecutor;
import com.github.dynamic.threadpool.starter.core.DynamicThreadPoolExecutor;
import com.github.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder;
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@ -23,26 +23,26 @@ import static com.github.dynamic.threadpool.example.constant.GlobalTestConstant.
public class ThreadPoolConfig {
/**
* {@link DynamicThreadPoolWrap} Server .
* {@link DynamicThreadPoolWrapper} Server .
*
* @return
*/
@Bean
public DynamicThreadPoolWrap messageCenterConsumeThreadPool() {
return new DynamicThreadPoolWrap(MESSAGE_CONSUME);
public DynamicThreadPoolWrapper messageCenterDynamicThreadPool() {
return new DynamicThreadPoolWrapper(MESSAGE_CONSUME);
}
/**
* {@link DynamicThreadPool} {@link CustomThreadPoolExecutor} Server .
* {@link DynamicThreadPool} {@link DynamicThreadPoolExecutor} Server .
* <p>
* 线, IOC {@link CustomThreadPoolExecutor}
* 线, IOC {@link DynamicThreadPoolExecutor}
*
* @return
*/
@Bean
@DynamicThreadPool
public ThreadPoolExecutor customThreadPoolExecutor() {
return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).isCustomPool(true).build();
public ThreadPoolExecutor dynamicThreadPoolExecutor() {
return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).dynamicPool().build();
}
}

@ -2,7 +2,7 @@ package com.github.dynamic.threadpool.example.inittest;
import cn.hutool.core.thread.ThreadUtil;
import com.github.dynamic.threadpool.starter.core.GlobalThreadPoolManage;
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -28,8 +28,8 @@ public class AlarmSendMessageTest {
public void alarmSendMessageTest() {
ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor();
scheduledThreadPool.scheduleWithFixedDelay(() -> {
DynamicThreadPoolWrap executorService = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE);
ThreadPoolExecutor poolExecutor = executorService.getPool();
DynamicThreadPoolWrapper poolWrapper = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE);
ThreadPoolExecutor poolExecutor = poolWrapper.getPool();
try {
poolExecutor.execute(() -> ThreadUtil.sleep(10240124));
} catch (Exception ex) {

@ -1,7 +1,7 @@
package com.github.dynamic.threadpool.example.inittest;
import com.github.dynamic.threadpool.starter.core.GlobalThreadPoolManage;
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
import com.github.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@ -30,8 +30,8 @@ public class RunStateHandlerTest {
ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor();
scheduledThreadPool.scheduleAtFixedRate(() -> {
DynamicThreadPoolWrap executorService = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE);
ThreadPoolExecutor pool = executorService.getPool();
DynamicThreadPoolWrapper poolWrapper = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE);
ThreadPoolExecutor pool = poolWrapper.getPool();
try {
pool.execute(() -> {
log.info("Thread pool name :: {}, Executing incoming blocking...", Thread.currentThread().getName());

Loading…
Cancel
Save