You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/09/22 06:49:06 UTC

[GitHub] [inlong] healchow commented on a diff in pull request #5852: [INLONG-5851][TubeMQ] Optimize while-sleep to ScheduledExecutorService in tubemq-manager

healchow commented on code in PR #5852:
URL: https://github.com/apache/inlong/pull/5852#discussion_r977258424


##########
inlong-tubemq/tubemq-manager/src/main/java/org/apache/inlong/tubemq/manager/service/TopicBackendWorker.java:
##########
@@ -136,5 +140,6 @@ public void run() {
     public void destroy() throws Exception {
         runFlag.set(false);
         nodeService.close();
+        this.workerExecutor.shutdown();

Review Comment:
   Maybe use `shutdownNow()`?



##########
inlong-tubemq/tubemq-manager/src/main/java/org/apache/inlong/tubemq/manager/service/TopicBackendWorker.java:
##########
@@ -67,9 +71,10 @@ public class TopicBackendWorker implements DisposableBean, Runnable  {
 
     TopicBackendWorker() {
         Thread thread = new Thread(this);
-        // daemon thread
-        thread.setDaemon(true);
-        thread.start();
+        this.workerExecutor = Executors
+                .newSingleThreadScheduledExecutor(

Review Comment:
   Introducing a package just to use a ThreadFactory is not a good solution.
   
   It is recommended to use the `com.google.common.util.concurrent.ThreadFactoryBuilder` class from the guava package to create a ThreadFactory.



-- 
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: commits-unsubscribe@inlong.apache.org

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