sun.misc.ThreadGroupUtils Java Examples

The following examples show how to use sun.misc.ThreadGroupUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CreatedFontTracker.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
                });
    }
}
 
Example #2
Source File: Win32ShellFolderManager2.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: LWToolkit.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: Win32ShellFolderManager2.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: D3DScreenUpdateManager.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #6
Source File: LWToolkit.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: D3DScreenUpdateManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example #8
Source File: CreatedFontTracker.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
                });
    }
}
 
Example #9
Source File: D3DScreenUpdateManager.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example #10
Source File: CreatedFontTracker.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
                });
    }
}
 
Example #11
Source File: CreatedFontTracker.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
                });
    }
}
 
Example #12
Source File: D3DScreenUpdateManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example #13
Source File: D3DScreenUpdateManager.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #14
Source File: LWToolkit.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #15
Source File: Win32ShellFolderManager2.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: D3DScreenUpdateManager.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #17
Source File: Win32ShellFolderManager2.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #18
Source File: CreatedFontTracker.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
                });
    }
}
 
Example #19
Source File: D3DScreenUpdateManager.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #20
Source File: D3DScreenUpdateManager.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #21
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example #22
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #23
Source File: LWToolkit.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #24
Source File: CreatedFontTracker.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
                });
    }
}
 
Example #25
Source File: Win32ShellFolderManager2.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #26
Source File: CreatedFontTracker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
                });
    }
}
 
Example #27
Source File: LWToolkit.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #28
Source File: D3DScreenUpdateManager.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #29
Source File: D3DScreenUpdateManager.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
            }
    );
}
 
Example #30
Source File: Win32ShellFolderManager2.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}