当前位置: 首页>>代码示例>>Java>>正文


Java ThreadGroupUtils.getRootThreadGroup方法代码示例

本文整理汇总了Java中sun.misc.ThreadGroupUtils.getRootThreadGroup方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadGroupUtils.getRootThreadGroup方法的具体用法?Java ThreadGroupUtils.getRootThreadGroup怎么用?Java ThreadGroupUtils.getRootThreadGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.misc.ThreadGroupUtils的用法示例。


在下文中一共展示了ThreadGroupUtils.getRootThreadGroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activateBlockerThread

import sun.misc.ThreadGroupUtils; //导入方法依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:AWTAutoShutdown.java

示例2: setDisplayMode

import sun.misc.ThreadGroupUtils; //导入方法依赖的package包/类
@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();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:58,代码来源:X11GraphicsDevice.java

示例3: setDisplayMode

import sun.misc.ThreadGroupUtils; //导入方法依赖的package包/类
@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);
                    if (isDisplayChangeSupported()) {
                        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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:60,代码来源:X11GraphicsDevice.java

示例4: run

import sun.misc.ThreadGroupUtils; //导入方法依赖的package包/类
@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();
    Thread t = new Thread(rootTG, disposerInstance, "Java2D Disposer");
    t.setContextClassLoader(null);
    t.setDaemon(true);
    t.setPriority(Thread.MAX_PRIORITY);
    t.start();
    return null;
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:15,代码来源:Disposer.java

示例5: setDisplayMode

import sun.misc.ThreadGroupUtils; //导入方法依赖的package包/类
@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 = new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
                Runnable r = new Runnable() {
                    @Override
                    public void run() {
                        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();
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:64,代码来源:X11GraphicsDevice.java

示例6: init

import sun.misc.ThreadGroupUtils; //导入方法依赖的package包/类
void init() {
    awtLock();
    try {
        XlibWrapper.XSupportsLocale();
        if (XlibWrapper.XSetLocaleModifiers("") == null) {
            log.finer("X locale modifiers are not supported, using default");
        }
        tryXKB();

        AwtScreenData defaultScreen = new AwtScreenData(XToolkit.getDefaultScreenData());
        awt_defaultFg = defaultScreen.get_blackpixel();

        arrowCursor = XlibWrapper.XCreateFontCursor(XToolkit.getDisplay(),
            XCursorFontConstants.XC_arrow);
        areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
        //set system property if not yet assigned
        System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
    } finally {
        awtUnlock();
    }
    PrivilegedAction<Void> a = new PrivilegedAction<Void>() {
        public Void run() {
            Thread shutdownThread = new Thread(ThreadGroupUtils.getRootThreadGroup(), "XToolkt-Shutdown-Thread") {
                    public void run() {
                        XSystemTrayPeer peer = XSystemTrayPeer.getPeerInstance();
                        if (peer != null) {
                            peer.dispose();
                        }
                        if (xs != null) {
                            ((XAWTXSettings)xs).dispose();
                        }
                        freeXKB();
                        if (log.isLoggable(PlatformLogger.FINE)) {
                            dumpPeers();
                        }
                    }
                };
            shutdownThread.setContextClassLoader(null);
            Runtime.getRuntime().addShutdownHook(shutdownThread);
            return null;
        }
    };
    AccessController.doPrivileged(a);
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:45,代码来源:XToolkit.java


注:本文中的sun.misc.ThreadGroupUtils.getRootThreadGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。