< prev index next >

src/java.desktop/share/classes/sun/awt/util/ThreadGroupUtils.java

Print this page

27 
28 /**
29  * A utility class needed to access the root {@code ThreadGroup}
30  *
31  * The class should not depend on any others, because it' called from JNI_OnLoad of the AWT
32  * native library. Triggering class loading could lead to a deadlock.
33  */
34 public final class ThreadGroupUtils {
35 
36     private ThreadGroupUtils() {
37         // Avoid instantiation
38     }
39 
40     /**
41      * Returns a root thread group.
42      * Should be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
43      *
44      * @return a root {@code ThreadGroup}
45      */
46     public static ThreadGroup getRootThreadGroup() {

47         ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
48         ThreadGroup parentTG = currentTG.getParent();
49         while (parentTG != null) {
50             currentTG = parentTG;
51             parentTG = currentTG.getParent();
52         }
53         return currentTG;
54     }
55 }

27 
28 /**
29  * A utility class needed to access the root {@code ThreadGroup}
30  *
31  * The class should not depend on any others, because it' called from JNI_OnLoad of the AWT
32  * native library. Triggering class loading could lead to a deadlock.
33  */
34 public final class ThreadGroupUtils {
35 
36     private ThreadGroupUtils() {
37         // Avoid instantiation
38     }
39 
40     /**
41      * Returns a root thread group.
42      * Should be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
43      *
44      * @return a root {@code ThreadGroup}
45      */
46     public static ThreadGroup getRootThreadGroup() {
47         @SuppressWarnings("deprecation")
48         ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
49         ThreadGroup parentTG = currentTG.getParent();
50         while (parentTG != null) {
51             currentTG = parentTG;
52             parentTG = currentTG.getParent();
53         }
54         return currentTG;
55     }
56 }
< prev index next >