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

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

@ -1,9 +1,9 @@
package com.github.dynamic.threadpool.example.config; package com.github.dynamic.threadpool.example.config;
import com.github.dynamic.threadpool.starter.core.DynamicThreadPool; 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.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 lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -23,26 +23,26 @@ import static com.github.dynamic.threadpool.example.constant.GlobalTestConstant.
public class ThreadPoolConfig { public class ThreadPoolConfig {
/** /**
* {@link DynamicThreadPoolWrap} Server . * {@link DynamicThreadPoolWrapper} Server .
* *
* @return * @return
*/ */
@Bean @Bean
public DynamicThreadPoolWrap messageCenterConsumeThreadPool() { public DynamicThreadPoolWrapper messageCenterDynamicThreadPool() {
return new DynamicThreadPoolWrap(MESSAGE_CONSUME); return new DynamicThreadPoolWrapper(MESSAGE_CONSUME);
} }
/** /**
* {@link DynamicThreadPool} {@link CustomThreadPoolExecutor} Server . * {@link DynamicThreadPool} {@link DynamicThreadPoolExecutor} Server .
* <p> * <p>
* 线, IOC {@link CustomThreadPoolExecutor} * 线, IOC {@link DynamicThreadPoolExecutor}
* *
* @return * @return
*/ */
@Bean @Bean
@DynamicThreadPool @DynamicThreadPool
public ThreadPoolExecutor customThreadPoolExecutor() { public ThreadPoolExecutor dynamicThreadPoolExecutor() {
return ThreadPoolBuilder.builder().threadFactory(MESSAGE_PRODUCE).isCustomPool(true).build(); 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 cn.hutool.core.thread.ThreadUtil;
import com.github.dynamic.threadpool.starter.core.GlobalThreadPoolManage; 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 lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -28,8 +28,8 @@ public class AlarmSendMessageTest {
public void alarmSendMessageTest() { public void alarmSendMessageTest() {
ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor(); ScheduledExecutorService scheduledThreadPool = Executors.newSingleThreadScheduledExecutor();
scheduledThreadPool.scheduleWithFixedDelay(() -> { scheduledThreadPool.scheduleWithFixedDelay(() -> {
DynamicThreadPoolWrap executorService = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE); DynamicThreadPoolWrapper poolWrapper = GlobalThreadPoolManage.getExecutorService(MESSAGE_PRODUCE);
ThreadPoolExecutor poolExecutor = executorService.getPool(); ThreadPoolExecutor poolExecutor = poolWrapper.getPool();
try { try {
poolExecutor.execute(() -> ThreadUtil.sleep(10240124)); poolExecutor.execute(() -> ThreadUtil.sleep(10240124));
} catch (Exception ex) { } catch (Exception ex) {

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

Loading…
Cancel
Save