Java 类sun.misc.ThreadGroupUtils 实例源码

项目:OpenJSharp    文件:CreatedFontTracker.java   
static void init() {
    if (t == null) {
        // Add a shutdown hook to remove the temp file.
        AccessController.doPrivileged(
                (PrivilegedAction<Void>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    t = new Thread(rootTG, TempFileDeletionHook::runHooks);
                    t.setContextClassLoader(null);
                    Runtime.getRuntime().addShutdownHook(t);
                    return null;
                });
    }
}
项目:OpenJSharp    文件:LWToolkit.java   
protected final void init() {
    AWTAutoShutdown.notifyToolkitThreadBusy();

    ThreadGroup rootTG = AccessController.doPrivileged(
            (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);

    Runtime.getRuntime().addShutdownHook(
        new Thread(rootTG, () -> {
            shutdown();
            waitForRunState(STATE_CLEANUP);
        })
    );

    Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
    toolkitThread.setDaemon(true);
    toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
    toolkitThread.start();

    waitForRunState(STATE_MESSAGELOOP);
}
项目:OpenJSharp    文件:D3DScreenUpdateManager.java   
public D3DScreenUpdateManager() {
    done = false;
    AccessController.doPrivileged(
            (PrivilegedAction<Void>) () -> {
                ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                Thread shutdown = new Thread(rootTG, () -> {
                    done = true;
                    wakeUpUpdateThread();
                });
                shutdown.setContextClassLoader(null);
                try {
                    Runtime.getRuntime().addShutdownHook(shutdown);
                } catch (Exception e) {
                    done = true;
                }
                return null;
            }
    );
}
项目:OpenJSharp    文件:D3DScreenUpdateManager.java   
/**
 * If the update thread hasn't yet been created, it will be;
 * otherwise it is awaken
 */
private synchronized void startUpdateThread() {
    if (screenUpdater == null) {
        screenUpdater = AccessController.doPrivileged(
                (PrivilegedAction<Thread>) () -> {
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread t = new Thread(rootTG,
                            D3DScreenUpdateManager.this,
                            "D3D Screen Updater");
                    // REMIND: should it be higher?
                    t.setPriority(Thread.NORM_PRIORITY + 2);
                    t.setDaemon(true);
                    return t;
                });
        screenUpdater.start();
    } else {
        wakeUpUpdateThread();
    }
}
项目:OpenJSharp    文件:Win32ShellFolderManager2.java   
public synchronized Thread newThread(final Runnable task) {
    final Runnable comRun = new Runnable() {
        public void run() {
            try {
                initializeCom();
                task.run();
            } finally {
                uninitializeCom();
            }
        }
    };
    comThread =  AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread thread = new Thread(rootTG, comRun, "Swing-Shell");
                    thread.setDaemon(true);
                    return thread;
                }
        );
    return comThread;
}
项目:jdk8u-jdk    文件:CreatedFontTracker.java   
static void init() {
    if (t == null) {
        // Add a shutdown hook to remove the temp file.
        AccessController.doPrivileged(
                (PrivilegedAction<Void>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    t = new Thread(rootTG, TempFileDeletionHook::runHooks);
                    t.setContextClassLoader(null);
                    Runtime.getRuntime().addShutdownHook(t);
                    return null;
                });
    }
}
项目:jdk8u-jdk    文件:LWToolkit.java   
protected final void init() {
    AWTAutoShutdown.notifyToolkitThreadBusy();

    ThreadGroup rootTG = AccessController.doPrivileged(
            (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);

    Runtime.getRuntime().addShutdownHook(
        new Thread(rootTG, () -> {
            shutdown();
            waitForRunState(STATE_CLEANUP);
        })
    );

    Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
    toolkitThread.setDaemon(true);
    toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
    toolkitThread.start();

    waitForRunState(STATE_MESSAGELOOP);
}
项目:jdk8u-jdk    文件:D3DScreenUpdateManager.java   
public D3DScreenUpdateManager() {
    done = false;
    AccessController.doPrivileged(
            (PrivilegedAction<Void>) () -> {
                ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                Thread shutdown = new Thread(rootTG, () -> {
                    done = true;
                    wakeUpUpdateThread();
                });
                shutdown.setContextClassLoader(null);
                try {
                    Runtime.getRuntime().addShutdownHook(shutdown);
                } catch (Exception e) {
                    done = true;
                }
                return null;
            }
    );
}
项目:jdk8u-jdk    文件:D3DScreenUpdateManager.java   
/**
 * If the update thread hasn't yet been created, it will be;
 * otherwise it is awaken
 */
private synchronized void startUpdateThread() {
    if (screenUpdater == null) {
        screenUpdater = AccessController.doPrivileged(
                (PrivilegedAction<Thread>) () -> {
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread t = new Thread(rootTG,
                            D3DScreenUpdateManager.this,
                            "D3D Screen Updater");
                    // REMIND: should it be higher?
                    t.setPriority(Thread.NORM_PRIORITY + 2);
                    t.setDaemon(true);
                    return t;
                });
        screenUpdater.start();
    } else {
        wakeUpUpdateThread();
    }
}
项目:jdk8u-jdk    文件:Win32ShellFolderManager2.java   
public synchronized Thread newThread(final Runnable task) {
    final Runnable comRun = new Runnable() {
        public void run() {
            try {
                initializeCom();
                task.run();
            } finally {
                uninitializeCom();
            }
        }
    };
    comThread =  AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread thread = new Thread(rootTG, comRun, "Swing-Shell");
                    thread.setDaemon(true);
                    return thread;
                }
        );
    return comThread;
}
项目:jdk8u_jdk    文件:CreatedFontTracker.java   
static void init() {
    if (t == null) {
        // Add a shutdown hook to remove the temp file.
        AccessController.doPrivileged(
                (PrivilegedAction<Void>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    t = new Thread(rootTG, TempFileDeletionHook::runHooks);
                    t.setContextClassLoader(null);
                    Runtime.getRuntime().addShutdownHook(t);
                    return null;
                });
    }
}
项目:jdk8u_jdk    文件:LWToolkit.java   
protected final void init() {
    AWTAutoShutdown.notifyToolkitThreadBusy();

    ThreadGroup rootTG = AccessController.doPrivileged(
            (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);

    Runtime.getRuntime().addShutdownHook(
        new Thread(rootTG, () -> {
            shutdown();
            waitForRunState(STATE_CLEANUP);
        })
    );

    Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
    toolkitThread.setDaemon(true);
    toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
    toolkitThread.start();

    waitForRunState(STATE_MESSAGELOOP);
}
项目:jdk8u_jdk    文件:D3DScreenUpdateManager.java   
public D3DScreenUpdateManager() {
    done = false;
    AccessController.doPrivileged(
            (PrivilegedAction<Void>) () -> {
                ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                Thread shutdown = new Thread(rootTG, () -> {
                    done = true;
                    wakeUpUpdateThread();
                });
                shutdown.setContextClassLoader(null);
                try {
                    Runtime.getRuntime().addShutdownHook(shutdown);
                } catch (Exception e) {
                    done = true;
                }
                return null;
            }
    );
}
项目:jdk8u_jdk    文件:D3DScreenUpdateManager.java   
/**
 * If the update thread hasn't yet been created, it will be;
 * otherwise it is awaken
 */
private synchronized void startUpdateThread() {
    if (screenUpdater == null) {
        screenUpdater = AccessController.doPrivileged(
                (PrivilegedAction<Thread>) () -> {
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread t = new Thread(rootTG,
                            D3DScreenUpdateManager.this,
                            "D3D Screen Updater");
                    // REMIND: should it be higher?
                    t.setPriority(Thread.NORM_PRIORITY + 2);
                    t.setDaemon(true);
                    return t;
                });
        screenUpdater.start();
    } else {
        wakeUpUpdateThread();
    }
}
项目:jdk8u_jdk    文件:Win32ShellFolderManager2.java   
public synchronized Thread newThread(final Runnable task) {
    final Runnable comRun = new Runnable() {
        public void run() {
            try {
                initializeCom();
                task.run();
            } finally {
                uninitializeCom();
            }
        }
    };
    comThread =  AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread thread = new Thread(rootTG, comRun, "Swing-Shell");
                    thread.setDaemon(true);
                    return thread;
                }
        );
    return comThread;
}
项目:lookaside_java-1.8.0-openjdk    文件:CreatedFontTracker.java   
static void init() {
    if (t == null) {
        // Add a shutdown hook to remove the temp file.
        AccessController.doPrivileged(
                (PrivilegedAction<Void>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    t = new Thread(rootTG, TempFileDeletionHook::runHooks);
                    t.setContextClassLoader(null);
                    Runtime.getRuntime().addShutdownHook(t);
                    return null;
                });
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:LWToolkit.java   
protected final void init() {
    AWTAutoShutdown.notifyToolkitThreadBusy();

    ThreadGroup rootTG = AccessController.doPrivileged(
            (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);

    Runtime.getRuntime().addShutdownHook(
        new Thread(rootTG, () -> {
            shutdown();
            waitForRunState(STATE_CLEANUP);
        })
    );

    Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
    toolkitThread.setDaemon(true);
    toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
    toolkitThread.start();

    waitForRunState(STATE_MESSAGELOOP);
}
项目:lookaside_java-1.8.0-openjdk    文件:D3DScreenUpdateManager.java   
public D3DScreenUpdateManager() {
    done = false;
    AccessController.doPrivileged(
            (PrivilegedAction<Void>) () -> {
                ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                Thread shutdown = new Thread(rootTG, () -> {
                    done = true;
                    wakeUpUpdateThread();
                });
                shutdown.setContextClassLoader(null);
                try {
                    Runtime.getRuntime().addShutdownHook(shutdown);
                } catch (Exception e) {
                    done = true;
                }
                return null;
            }
    );
}
项目:lookaside_java-1.8.0-openjdk    文件:D3DScreenUpdateManager.java   
/**
 * If the update thread hasn't yet been created, it will be;
 * otherwise it is awaken
 */
private synchronized void startUpdateThread() {
    if (screenUpdater == null) {
        screenUpdater = AccessController.doPrivileged(
                (PrivilegedAction<Thread>) () -> {
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread t = new Thread(rootTG,
                            D3DScreenUpdateManager.this,
                            "D3D Screen Updater");
                    // REMIND: should it be higher?
                    t.setPriority(Thread.NORM_PRIORITY + 2);
                    t.setDaemon(true);
                    return t;
                });
        screenUpdater.start();
    } else {
        wakeUpUpdateThread();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Win32ShellFolderManager2.java   
public synchronized Thread newThread(final Runnable task) {
    final Runnable comRun = new Runnable() {
        public void run() {
            try {
                initializeCom();
                task.run();
            } finally {
                uninitializeCom();
            }
        }
    };
    comThread =  AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread thread = new Thread(rootTG, comRun, "Swing-Shell");
                    thread.setDaemon(true);
                    return thread;
                }
        );
    return comThread;
}
项目:infobip-open-jdk-8    文件:CreatedFontTracker.java   
static void init() {
    if (t == null) {
        // Add a shutdown hook to remove the temp file.
        AccessController.doPrivileged(
                (PrivilegedAction<Void>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    t = new Thread(rootTG, TempFileDeletionHook::runHooks);
                    t.setContextClassLoader(null);
                    Runtime.getRuntime().addShutdownHook(t);
                    return null;
                });
    }
}
项目:infobip-open-jdk-8    文件:LWToolkit.java   
protected final void init() {
    AWTAutoShutdown.notifyToolkitThreadBusy();

    ThreadGroup rootTG = AccessController.doPrivileged(
            (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);

    Runtime.getRuntime().addShutdownHook(
        new Thread(rootTG, () -> {
            shutdown();
            waitForRunState(STATE_CLEANUP);
        })
    );

    Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
    toolkitThread.setDaemon(true);
    toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
    toolkitThread.start();

    waitForRunState(STATE_MESSAGELOOP);
}
项目:infobip-open-jdk-8    文件:D3DScreenUpdateManager.java   
public D3DScreenUpdateManager() {
    done = false;
    AccessController.doPrivileged(
            (PrivilegedAction<Void>) () -> {
                ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                Thread shutdown = new Thread(rootTG, () -> {
                    done = true;
                    wakeUpUpdateThread();
                });
                shutdown.setContextClassLoader(null);
                try {
                    Runtime.getRuntime().addShutdownHook(shutdown);
                } catch (Exception e) {
                    done = true;
                }
                return null;
            }
    );
}
项目:infobip-open-jdk-8    文件:D3DScreenUpdateManager.java   
/**
 * If the update thread hasn't yet been created, it will be;
 * otherwise it is awaken
 */
private synchronized void startUpdateThread() {
    if (screenUpdater == null) {
        screenUpdater = AccessController.doPrivileged(
                (PrivilegedAction<Thread>) () -> {
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread t = new Thread(rootTG,
                            D3DScreenUpdateManager.this,
                            "D3D Screen Updater");
                    // REMIND: should it be higher?
                    t.setPriority(Thread.NORM_PRIORITY + 2);
                    t.setDaemon(true);
                    return t;
                });
        screenUpdater.start();
    } else {
        wakeUpUpdateThread();
    }
}
项目:infobip-open-jdk-8    文件:Win32ShellFolderManager2.java   
public synchronized Thread newThread(final Runnable task) {
    final Runnable comRun = new Runnable() {
        public void run() {
            try {
                initializeCom();
                task.run();
            } finally {
                uninitializeCom();
            }
        }
    };
    comThread =  AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread thread = new Thread(rootTG, comRun, "Swing-Shell");
                    thread.setDaemon(true);
                    return thread;
                }
        );
    return comThread;
}
项目:jdk8u-dev-jdk    文件:CreatedFontTracker.java   
static void init() {
    if (t == null) {
        // Add a shutdown hook to remove the temp file.
        AccessController.doPrivileged(
                (PrivilegedAction<Void>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    t = new Thread(rootTG, TempFileDeletionHook::runHooks);
                    t.setContextClassLoader(null);
                    Runtime.getRuntime().addShutdownHook(t);
                    return null;
                });
    }
}
项目:jdk8u-dev-jdk    文件:LWToolkit.java   
protected final void init() {
    AWTAutoShutdown.notifyToolkitThreadBusy();

    ThreadGroup rootTG = AccessController.doPrivileged(
            (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);

    Runtime.getRuntime().addShutdownHook(
        new Thread(rootTG, () -> {
            shutdown();
            waitForRunState(STATE_CLEANUP);
        })
    );

    Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
    toolkitThread.setDaemon(true);
    toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
    toolkitThread.start();

    waitForRunState(STATE_MESSAGELOOP);
}
项目:jdk8u-dev-jdk    文件:D3DScreenUpdateManager.java   
public D3DScreenUpdateManager() {
    done = false;
    AccessController.doPrivileged(
            (PrivilegedAction<Void>) () -> {
                ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                Thread shutdown = new Thread(rootTG, () -> {
                    done = true;
                    wakeUpUpdateThread();
                });
                shutdown.setContextClassLoader(null);
                try {
                    Runtime.getRuntime().addShutdownHook(shutdown);
                } catch (Exception e) {
                    done = true;
                }
                return null;
            }
    );
}
项目:jdk8u-dev-jdk    文件:D3DScreenUpdateManager.java   
/**
 * If the update thread hasn't yet been created, it will be;
 * otherwise it is awaken
 */
private synchronized void startUpdateThread() {
    if (screenUpdater == null) {
        screenUpdater = AccessController.doPrivileged(
                (PrivilegedAction<Thread>) () -> {
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread t = new Thread(rootTG,
                            D3DScreenUpdateManager.this,
                            "D3D Screen Updater");
                    // REMIND: should it be higher?
                    t.setPriority(Thread.NORM_PRIORITY + 2);
                    t.setDaemon(true);
                    return t;
                });
        screenUpdater.start();
    } else {
        wakeUpUpdateThread();
    }
}
项目:jdk8u-dev-jdk    文件:Win32ShellFolderManager2.java   
public synchronized Thread newThread(final Runnable task) {
    final Runnable comRun = new Runnable() {
        public void run() {
            try {
                initializeCom();
                task.run();
            } finally {
                uninitializeCom();
            }
        }
    };
    comThread =  AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread thread = new Thread(rootTG, comRun, "Swing-Shell");
                    thread.setDaemon(true);
                    return thread;
                }
        );
    return comThread;
}
项目:openjdk-jdk7u-jdk    文件:CreatedFontTracker.java   
static void init() {
    if (t == null) {
        // Add a shutdown hook to remove the temp file.
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
                    @Override
                    public Void run() {
                    /* The thread must be a member of a thread group
                     * which will not get GCed before VM exit.
                     * Make its parent the top-level thread group.
                     */
                        ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                        t = new Thread(rootTG, new Runnable() {
                            @Override
                            public void run() {
                                runHooks();
                            }
                        });
                        t.setContextClassLoader(null);
                        Runtime.getRuntime().addShutdownHook(t);
                        return null;
                    }
                });
    }
}
项目:openjdk-jdk7u-jdk    文件:D3DScreenUpdateManager.java   
public D3DScreenUpdateManager() {
    done = false;
    AccessController.doPrivileged(
            new PrivilegedAction<Void>() {
                @Override
                public Void run() {
                    ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                    Thread shutdown = new Thread(rootTG, new Runnable() {
                        @Override
                        public void run() {
                            done = true;
                            wakeUpUpdateThread();
                        }
                    });
                    shutdown.setContextClassLoader(null);
                    try {
                        Runtime.getRuntime().addShutdownHook(shutdown);
                    } catch (Exception e) {
                        done = true;
                    }
                    return null;
                }
            }
    );
}
项目:openjdk-jdk7u-jdk    文件:D3DScreenUpdateManager.java   
/**
 * If the update thread hasn't yet been created, it will be;
 * otherwise it is awaken
 */
private synchronized void startUpdateThread() {
    if (screenUpdater == null) {
        screenUpdater = AccessController.doPrivileged(
                new PrivilegedAction<Thread>() {
                    @Override
                    public Thread run() {
                        ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                        Thread t = new Thread(rootTG,
                                D3DScreenUpdateManager.this,
                                "D3D Screen Updater");
                        // REMIND: should it be higher?
                        t.setPriority(Thread.NORM_PRIORITY + 2);
                        t.setDaemon(true);
                        return t;
                    }
                });
        screenUpdater.start();
    } else {
        wakeUpUpdateThread();
    }
}
项目:OpenJSharp    文件:OGLRenderQueue.java   
private OGLRenderQueue() {
    /*
     * The thread must be a member of a thread group
     * which will not get GCed before VM exit.
     */
    flusher = AccessController.doPrivileged((PrivilegedAction<QueueFlusher>) () -> {
        return new QueueFlusher(ThreadGroupUtils.getRootThreadGroup());
    });
}
项目:OpenJSharp    文件:AWTAutoShutdown.java   
/**
 * Creates and starts a new blocker thread. Doesn't return until
 * the new blocker thread starts.
 *
 * Must be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
 */
private void activateBlockerThread() {
    Thread thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, "AWT-Shutdown");
    thread.setContextClassLoader(null);
    thread.setDaemon(false);
    blockerThread = thread;
    thread.start();
    try {
        /* Wait for the blocker thread to start. */
        mainLock.wait();
    } catch (InterruptedException e) {
        System.err.println("AWT blocker activation interrupted:");
        e.printStackTrace();
    }
}
项目:OpenJSharp    文件:WToolkit.java   
private final void registerShutdownHook() {
   AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
       Thread shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
       shutdown.setContextClassLoader(null);
       Runtime.getRuntime().addShutdownHook(shutdown);
       return null;
   });
}
项目:OpenJSharp    文件:X11GraphicsDevice.java   
@Override
public synchronized void setDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        super.setDisplayMode(dm);
        return;
    }
    Window w = getFullScreenWindow();
    if (w == null) {
        throw new IllegalStateException("Must be in fullscreen mode " +
                                        "in order to set display mode");
    }
    if (getDisplayMode().equals(dm)) {
        return;
    }
    if (dm == null ||
        (dm = getMatchingDisplayMode(dm)) == null)
    {
        throw new IllegalArgumentException("Invalid display mode");
    }

    if (!shutdownHookRegistered) {
        // register a shutdown hook so that we return to the
        // original DisplayMode when the VM exits (if the application
        // is already in the original DisplayMode at that time, this
        // hook will have no effect)
        shutdownHookRegistered = true;
        PrivilegedAction<Void> a = () -> {
            ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
            Runnable r = () -> {
                Window old = getFullScreenWindow();
                if (old != null) {
                    exitFullScreenExclusive(old);
                    setDisplayMode(origDisplayMode);
                }
            };
            Thread t = new Thread(rootTG, r,"Display-Change-Shutdown-Thread-"+screen);
            t.setContextClassLoader(null);
            Runtime.getRuntime().addShutdownHook(t);
            return null;
        };
        AccessController.doPrivileged(a);
    }

    // switch to the new DisplayMode
    configDisplayMode(screen,
                      dm.getWidth(), dm.getHeight(),
                      dm.getRefreshRate());

    // update bounds of the fullscreen window
    w.setBounds(0, 0, dm.getWidth(), dm.getHeight());

    // configDisplayMode() is synchronous, so the display change will be
    // complete by the time we get here (and it is therefore safe to call
    // displayChanged() now)
    ((X11GraphicsEnvironment)
     GraphicsEnvironment.getLocalGraphicsEnvironment()).displayChanged();
}
项目:jdk8u-jdk    文件:OGLRenderQueue.java   
private OGLRenderQueue() {
    /*
     * The thread must be a member of a thread group
     * which will not get GCed before VM exit.
     */
    flusher = AccessController.doPrivileged((PrivilegedAction<QueueFlusher>) () -> {
        return new QueueFlusher(ThreadGroupUtils.getRootThreadGroup());
    });
}
项目:jdk8u-jdk    文件:AWTAutoShutdown.java   
/**
 * Creates and starts a new blocker thread. Doesn't return until
 * the new blocker thread starts.
 *
 * Must be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
 */
private void activateBlockerThread() {
    Thread thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, "AWT-Shutdown");
    thread.setContextClassLoader(null);
    thread.setDaemon(false);
    blockerThread = thread;
    thread.start();
    try {
        /* Wait for the blocker thread to start. */
        mainLock.wait();
    } catch (InterruptedException e) {
        System.err.println("AWT blocker activation interrupted:");
        e.printStackTrace();
    }
}
项目:jdk8u-jdk    文件:WToolkit.java   
private final void registerShutdownHook() {
   AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
       Thread shutdown = new Thread(ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
       shutdown.setContextClassLoader(null);
       Runtime.getRuntime().addShutdownHook(shutdown);
       return null;
   });
}