< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java

Print this page




 228 
 229     public WToolkit() {
 230         // Startup toolkit threads
 231         if (PerformanceLogger.loggingEnabled()) {
 232             PerformanceLogger.setTime("WToolkit construction");
 233         }
 234 
 235         sun.java2d.Disposer.addRecord(anchor, new ToolkitDisposer());
 236 
 237         /*
 238          * Fix for 4701990.
 239          * AWTAutoShutdown state must be changed before the toolkit thread
 240          * starts to avoid race condition.
 241          */
 242         AWTAutoShutdown.notifyToolkitThreadBusy();
 243 
 244         // Find a root TG and attach toolkit thread to it
 245         ThreadGroup rootTG = AccessController.doPrivileged(
 246                 (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
 247         if (!startToolkitThread(this, rootTG)) {
 248             String name = "AWT-Windows";

 249             Thread toolkitThread = new Thread(rootTG, this, name, 0, false);
 250             toolkitThread.setDaemon(true);
 251             toolkitThread.start();


 252         }
 253 
 254         try {
 255             synchronized(this) {
 256                 while(!inited) {
 257                     wait();
 258                 }
 259             }
 260         } catch (InterruptedException x) {
 261             // swallow the exception
 262         }
 263 
 264         // Enabled "live resizing" by default.  It remains controlled
 265         // by the native system though.
 266         setDynamicLayout(true);
 267 
 268         areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));


 269         //set system property if not yet assigned
 270         System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);


 271         setExtraMouseButtonsEnabledNative(areExtraMouseButtonsEnabled);
 272     }
 273 
 274     private void registerShutdownHook() {
 275         AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
 276             Thread shutdown = new Thread(
 277                     ThreadGroupUtils.getRootThreadGroup(), this::shutdown,
 278                     "ToolkitShutdown", 0, false);
 279             shutdown.setContextClassLoader(null);
 280             Runtime.getRuntime().addShutdownHook(shutdown);
 281             return null;
 282         });
 283      }
 284 
 285     @Override
 286     public void run() {
 287         AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
 288             Thread.currentThread().setContextClassLoader(null);
 289             Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 1);
 290             return null;




 228 
 229     public WToolkit() {
 230         // Startup toolkit threads
 231         if (PerformanceLogger.loggingEnabled()) {
 232             PerformanceLogger.setTime("WToolkit construction");
 233         }
 234 
 235         sun.java2d.Disposer.addRecord(anchor, new ToolkitDisposer());
 236 
 237         /*
 238          * Fix for 4701990.
 239          * AWTAutoShutdown state must be changed before the toolkit thread
 240          * starts to avoid race condition.
 241          */
 242         AWTAutoShutdown.notifyToolkitThreadBusy();
 243 
 244         // Find a root TG and attach toolkit thread to it
 245         ThreadGroup rootTG = AccessController.doPrivileged(
 246                 (PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
 247         if (!startToolkitThread(this, rootTG)) {
 248             final String name = "AWT-Windows";
 249             AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
 250                 Thread toolkitThread = new Thread(rootTG, this, name, 0, false);
 251                 toolkitThread.setDaemon(true);
 252                 toolkitThread.start();
 253                 return null;
 254             });
 255         }
 256 
 257         try {
 258             synchronized(this) {
 259                 while(!inited) {
 260                     wait();
 261                 }
 262             }
 263         } catch (InterruptedException x) {
 264             // swallow the exception
 265         }
 266 
 267         // Enabled "live resizing" by default.  It remains controlled
 268         // by the native system though.
 269         setDynamicLayout(true);
 270         final String extraButtons = "sun.awt.enableExtraMouseButtons";
 271         AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
 272             areExtraMouseButtonsEnabled =
 273                  Boolean.parseBoolean(System.getProperty(extraButtons, "true"));
 274             //set system property if not yet assigned
 275             System.setProperty(extraButtons, ""+areExtraMouseButtonsEnabled);
 276             return null;
 277         });
 278         setExtraMouseButtonsEnabledNative(areExtraMouseButtonsEnabled);
 279     }
 280 
 281     private void registerShutdownHook() {
 282         AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
 283             Thread shutdown = new Thread(
 284                     ThreadGroupUtils.getRootThreadGroup(), this::shutdown,
 285                     "ToolkitShutdown", 0, false);
 286             shutdown.setContextClassLoader(null);
 287             Runtime.getRuntime().addShutdownHook(shutdown);
 288             return null;
 289         });
 290      }
 291 
 292     @Override
 293     public void run() {
 294         AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
 295             Thread.currentThread().setContextClassLoader(null);
 296             Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 1);
 297             return null;


< prev index next >