Java Code Examples for sun.misc.ThreadGroupUtils

The following examples show how to use sun.misc.ThreadGroupUtils. These examples are extracted from open source projects. 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
/**
 * 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 2
Source Project: dragonwell8_jdk   Source File: LWToolkit.java    License: 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 3
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 4
/**
 * 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 5
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 6
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 7
Source Project: TencentKona-8   Source File: LWToolkit.java    License: 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 8
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 9
/**
 * 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
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 11
Source Project: jdk8u60   Source File: CreatedFontTracker.java    License: 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 Project: jdk8u-jdk   Source File: CreatedFontTracker.java    License: 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 13
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
/**
 * 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 15
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
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 17
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 18
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
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 20
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
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 22
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 23
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 24
Source Project: jdk8u-jdk   Source File: CreatedFontTracker.java    License: 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 Project: jdk8u-jdk   Source File: LWToolkit.java    License: 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 26
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 27
/**
 * 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 28
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
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 30
Source Project: hottub   Source File: CreatedFontTracker.java    License: 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;
                });
    }
}