jdk/test/java/lang/management/ThreadMXBean/DisableTest.java
changeset 5808 3a1f603c5ca7
parent 5506 202f599c92aa
child 7668 d4a77089c587
--- a/jdk/test/java/lang/management/ThreadMXBean/DisableTest.java	Fri Jun 18 16:16:51 2010 +0100
+++ b/jdk/test/java/lang/management/ThreadMXBean/DisableTest.java	Fri Jun 18 09:35:22 2010 -0700
@@ -36,8 +36,18 @@
     private static ThreadMXBean tm = ManagementFactory.getThreadMXBean();
 
     public static void main(String args[]) throws Exception {
-        testThreadContentionMonitoring();
-        testThreadCpuMonitoring();
+        try {
+            testThreadContentionMonitoring();
+            testThreadCpuMonitoring();
+        } finally {
+            // restore the default
+            if (tm.isThreadContentionMonitoringSupported()) {
+                tm.setThreadContentionMonitoringEnabled(false);
+            }
+            if (tm.isThreadCpuTimeSupported()) {
+                tm.setThreadCpuTimeEnabled(false);
+            }
+        }
 
         System.out.println("Test passed.");
     }