< prev index next >

src/java.desktop/share/classes/sun/awt/AppContext.java

Print this page
@@ -259,10 +259,11 @@
          // On the main Thread, we get the ThreadGroup, make a corresponding
          // AppContext, and instantiate the Java EventQueue.  This way, legacy
          // code is unaffected by the move to multiple AppContext ability.
          AccessController.doPrivileged(new PrivilegedAction<Void>() {
              public Void run() {
+                 @SuppressWarnings("deprecation")
                  ThreadGroup currentThreadGroup =
                          Thread.currentThread().getThreadGroup();
                  ThreadGroup parentThreadGroup = currentThreadGroup.getParent();
                  while (parentThreadGroup != null) {
                      // Find the root ThreadGroup to construct our main AppContext

@@ -299,10 +300,11 @@
                  public AppContext run() {
                      // Get the current ThreadGroup, and look for it and its
                      // parents in the hash from ThreadGroup to AppContext --
                      // it should be found, because we use createNewContext()
                      // when new AppContext objects are created.
+                     @SuppressWarnings("deprecation")
                      ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup();
                      ThreadGroup threadGroup = currentThreadGroup;
  
                      // Special case: we implicitly create the main app context
                      // if no contexts have been created yet. This covers standalone apps

@@ -327,10 +329,11 @@
                          if (threadGroup == null) {
                              // We've got up to the root thread group and did not find an AppContext
                              // Try to get it from the security manager
                              SecurityManager securityManager = System.getSecurityManager();
                              if (securityManager != null) {
+                                 @SuppressWarnings("deprecation")
                                  ThreadGroup smThreadGroup = securityManager.getThreadGroup();
                                  if (smThreadGroup != null) {
                                      /*
                                       * If we get this far then it's likely that
                                       * the ThreadGroup does not actually belong

@@ -502,11 +505,16 @@
              } catch (InterruptedException e) { }
          }
  
          // Then, we stop any remaining Threads
          AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-             threadGroup.stop();
+             int threadCount = threadGroup.activeCount() + 16;
+             Thread[] threads = new Thread[threadCount];
+             threadCount = threadGroup.enumerate(threads);
+             for (int i = 0; i < threadCount; i++) {
+                 threads[i].stop();
+             }
              return null;
          });
  
          // Next, we sleep 10ms at a time, waiting for all of the active
          // Threads in the ThreadGroup to die.

@@ -572,10 +580,11 @@
              appContext = ac;
              runnable = r;
          }
  
          public Thread run() {
+             @SuppressWarnings("deprecation")
              Thread t = new Thread(appContext.getThreadGroup(),
                                    runnable, "AppContext Disposer", 0, false);
              t.setContextClassLoader(appContext.getContextClassLoader());
              t.setPriority(Thread.NORM_PRIORITY + 1);
              t.setDaemon(true);
< prev index next >