本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}