changeset 11794:bfe9a4d1fa70

8042327: Enhance thread contexts in serviceability Reviewed-by: chegar, dfuchs, olagneau, sla
author jbachorik
date Fri, 01 Aug 2014 13:31:03 +0200
parents 4555c1fe759c
children db8698ee7e77
files src/java.management/share/classes/com/sun/jmx/remote/internal/ClientCommunicatorAdmin.java src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java src/java.management/share/classes/com/sun/jmx/remote/internal/ServerCommunicatorAdmin.java src/java.management/share/classes/javax/management/monitor/Monitor.java src/java.management/share/classes/sun/management/jdp/JdpController.java
diffstat 5 files changed, 23 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientCommunicatorAdmin.java	Thu Apr 02 11:43:11 2015 +0100
+++ b/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientCommunicatorAdmin.java	Fri Aug 01 13:31:03 2014 +0200
@@ -30,6 +30,7 @@
 
 import com.sun.jmx.remote.util.ClassLogger;
 import com.sun.jmx.remote.util.EnvHelp;
+import sun.misc.ManagedLocalsThread;
 
 public abstract class ClientCommunicatorAdmin {
     private static volatile long threadNo = 1;
@@ -40,7 +41,11 @@
         if (period > 0) {
             checker = new Checker();
 
-            Thread t = new Thread(checker, "JMX client heartbeat " + ++threadNo);
+            Thread t = new ManagedLocalsThread(
+                checker,
+                "JMX client heartbeat " +  (++threadNo)
+            );
+
             t.setDaemon(true);
             t.start();
         } else
--- a/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Thu Apr 02 11:43:11 2015 +0100
+++ b/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Fri Aug 01 13:31:03 2014 +0200
@@ -52,6 +52,7 @@
 import com.sun.jmx.remote.util.ClassLogger;
 import com.sun.jmx.remote.util.EnvHelp;
 import java.rmi.UnmarshalException;
+import sun.misc.ManagedLocalsThread;
 
 
 public abstract class ClientNotifForwarder {
@@ -90,10 +91,8 @@
                 throw new IllegalArgumentException("More than one command");
             this.command = command;
             if (thread == null) {
-                thread = new Thread() {
-
-                    @Override
-                    public void run() {
+                thread = new ManagedLocalsThread(
+                    ()-> {
                         while (true) {
                             Runnable r;
                             synchronized (LinearExecutor.this) {
@@ -107,10 +106,10 @@
                             }
                             r.run();
                         }
-                    }
-                };
+                    },
+                    "ClientNotifForwarder-" + ++threadId
+                );
                 thread.setDaemon(true);
-                thread.setName("ClientNotifForwarder-" + ++threadId);
                 thread.start();
             }
         }
--- a/src/java.management/share/classes/com/sun/jmx/remote/internal/ServerCommunicatorAdmin.java	Thu Apr 02 11:43:11 2015 +0100
+++ b/src/java.management/share/classes/com/sun/jmx/remote/internal/ServerCommunicatorAdmin.java	Fri Aug 01 13:31:03 2014 +0200
@@ -25,9 +25,9 @@
 
 package com.sun.jmx.remote.internal;
 
-import java.io.IOException;
 
 import com.sun.jmx.remote.util.ClassLogger;
+import sun.misc.ManagedLocalsThread;
 
 public abstract class ServerCommunicatorAdmin {
     public ServerCommunicatorAdmin(long timeout) {
@@ -42,7 +42,7 @@
         timestamp = 0;
         if (timeout < Long.MAX_VALUE) {
             Runnable timeoutTask = new Timeout();
-            final Thread t = new Thread(timeoutTask);
+            final Thread t = new ManagedLocalsThread(timeoutTask);
             t.setName("JMX server connection timeout " + t.getId());
             // If you change this name you will need to change a unit test
             // (NoServerTimeoutTest)
--- a/src/java.management/share/classes/javax/management/monitor/Monitor.java	Thu Apr 02 11:43:11 2015 +0100
+++ b/src/java.management/share/classes/javax/management/monitor/Monitor.java	Fri Aug 01 13:31:03 2014 +0200
@@ -61,6 +61,7 @@
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
 import static javax.management.monitor.MonitorNotification.*;
+import sun.misc.ManagedLocalsThread;
 
 /**
  * Defines the part common to all monitor MBeans.
@@ -1636,12 +1637,12 @@
         }
 
         public Thread newThread(Runnable r) {
-            Thread t = new Thread(group,
-                                  r,
-                                  namePrefix +
-                                  threadNumber.getAndIncrement() +
-                                  nameSuffix,
-                                  0);
+            Thread t = new ManagedLocalsThread(
+                group,
+                r,
+                namePrefix + threadNumber.getAndIncrement() + nameSuffix
+            );
+
             t.setDaemon(true);
             if (t.getPriority() != Thread.NORM_PRIORITY)
                 t.setPriority(Thread.NORM_PRIORITY);
--- a/src/java.management/share/classes/sun/management/jdp/JdpController.java	Thu Apr 02 11:43:11 2015 +0100
+++ b/src/java.management/share/classes/sun/management/jdp/JdpController.java	Fri Aug 01 13:31:03 2014 +0200
@@ -34,6 +34,7 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import sun.management.VMManagement;
+import sun.misc.ManagedLocalsThread;
 
 /**
  * JdpController is responsible to create and manage a broadcast loop
@@ -219,7 +220,7 @@
 
         controller = new JDPControllerRunner(bcast, packet, pause);
 
-        Thread t = new Thread(controller, "JDP broadcaster");
+        Thread t = new ManagedLocalsThread(controller, "JDP broadcaster");
         t.setDaemon(true);
         t.start();
     }