You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/04/26 02:05:03 UTC

[GitHub] [rocketmq] cserwen commented on a diff in pull request #4208: [Optimization] Replace Timer to ScheduleExecutorService

cserwen commented on code in PR #4208:
URL: https://github.com/apache/rocketmq/pull/4208#discussion_r858170216


##########
example/src/main/java/org/apache/rocketmq/example/benchmark/BatchProducer.java:
##########
@@ -317,7 +320,8 @@ class StatsBenchmarkBatchProducer {
 
     private final LongAdder sendMessageFailedCount = new LongAdder();
 
-    private final Timer timer = new Timer("BenchmarkTimerThread", true);
+    private final ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1,
+            new BasicThreadFactory.Builder().namingPattern("BenchmarkTimerThread-%d").daemon(true).build());

Review Comment:
   Maybe it's better to use `ThreadFactoryImpl`, just like this:
   https://github.com/apache/rocketmq/blob/5d0102396031b728f9accfa5a562fe20906ac424/broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java#L136



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org