This is an automated email from the ASF dual-hosted git repository.

sarvekshayr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 68f3d3c4ea9 HDDS-16406. Remove deprecated ThreadGroup.isDestroyed() 
and ThreadGroup.destroy() (#11248)
68f3d3c4ea9 is described below

commit 68f3d3c4ea9d4c284a5d53607f6038856e2ff1e8
Author: Sarveksha Yeshavantha Raju 
<[email protected]>
AuthorDate: Wed Sep 16 15:38:13 2026 +0530

    HDDS-16406. Remove deprecated ThreadGroup.isDestroyed() and 
ThreadGroup.destroy() (#11248)
---
 .../org/apache/hadoop/hdds/utils/BackgroundService.java    | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java
 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java
index 28e59d551bd..89d6c032345 100644
--- 
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java
+++ 
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/BackgroundService.java
@@ -41,7 +41,6 @@ public abstract class BackgroundService {
 
   // Executor to launch child tasks
   private ScheduledThreadPoolExecutor exec;
-  private ThreadGroup threadGroup;
   private final String serviceName;
   private long interval;
   private volatile long serviceTimeoutInNanos;
@@ -66,7 +65,7 @@ public BackgroundService(String serviceName, long interval,
             .toLong(TimeUnit.NANOSECONDS);
     this.threadPoolSize = threadPoolSize;
     this.threadNamePrefix = threadNamePrefix;
-    initExecutorAndThreadGroup();
+    initExecutor();
     service = new PeriodicalTask();
     this.future = CompletableFuture.completedFuture(null);
   }
@@ -99,7 +98,7 @@ public synchronized void setServiceTimeoutInNanos(long 
newTimeout) {
 
   @VisibleForTesting
   public int getThreadCount() {
-    return threadGroup.activeCount();
+    return exec.getPoolSize();
   }
 
   @VisibleForTesting
@@ -114,7 +113,7 @@ public void runPeriodicalTaskNow() throws Exception {
   // start service
   public synchronized void start() {
     if (exec == null || exec.isShutdown() || exec.isTerminated()) {
-      initExecutorAndThreadGroup();
+      initExecutor();
     }
     LOG.info("Starting service {} with interval {} {}", serviceName,
         interval, unit.name().toLowerCase());
@@ -211,15 +210,10 @@ public void shutdown() {
       Thread.currentThread().interrupt();
       current.shutdownNow();
     }
-    if (threadGroup.activeCount() == 0 && !threadGroup.isDestroyed()) {
-      threadGroup.destroy();
-    }
   }
 
-  private void initExecutorAndThreadGroup() {
-    threadGroup = new ThreadGroup(serviceName);
+  private void initExecutor() {
     ThreadFactory threadFactory = new ThreadFactoryBuilder()
-        .setThreadFactory(r -> new Thread(threadGroup, r))
         .setDaemon(true)
         .setNameFormat(threadNamePrefix + serviceName + "#%d")
         .build();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to