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:47:48 UTC

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

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


##########
example/src/main/java/org/apache/rocketmq/example/benchmark/BatchProducer.java:
##########
@@ -360,17 +364,17 @@ public LongAdder getSendMessageFailedCount() {
 
     public void start() {
 
-        timer.scheduleAtFixedRate(new TimerTask() {
+        executorService.scheduleAtFixedRate(new TimerTask() {

Review Comment:
   It seems better to implement Runnable anonymously



##########
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:
   A unified style is recommended



-- 
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