< prev index next >

src/java.base/share/classes/jdk/internal/logger/BootstrapLogger.java

Print this page




 118                 executor = ref == null ? null : ref.get();
 119                 if (executor == null) {
 120                     executor = new ThreadPoolExecutor(0, 1,
 121                             KEEP_EXECUTOR_ALIVE_SECONDS, TimeUnit.SECONDS,
 122                             new LinkedBlockingQueue<>(), new BootstrapExecutors());
 123                 }
 124                 // The executor service will be elligible for gc
 125                 // KEEP_EXECUTOR_ALIVE_SECONDS seconds (30s)
 126                 // after the execution of its last pending task.
 127                 executorRef = new WeakReference<>(executor);
 128                 return executorRef.get();
 129             }
 130         }
 131 
 132         @Override
 133         public Thread newThread(Runnable r) {
 134             ExecutorService owner = getExecutor();
 135             Thread thread = AccessController.doPrivileged(new PrivilegedAction<Thread>() {
 136                 @Override
 137                 public Thread run() {
 138                     Thread t = new InnocuousThread(new BootstrapMessageLoggerTask(owner, r));
 139                     t.setName("BootstrapMessageLoggerTask-"+t.getName());
 140                     return t;
 141                 }
 142             }, null, new RuntimePermission("enableContextClassLoaderOverride"));
 143             thread.setDaemon(true);
 144             return thread;
 145         }
 146 
 147         static void submit(Runnable r) {
 148             getExecutor().execute(r);
 149         }
 150 
 151         // This is used by tests.
 152         static void join(Runnable r) {
 153             try {
 154                 getExecutor().submit(r).get();
 155             } catch (InterruptedException | ExecutionException ex) {
 156                 // should not happen
 157                 throw new RuntimeException(ex);
 158             }




 118                 executor = ref == null ? null : ref.get();
 119                 if (executor == null) {
 120                     executor = new ThreadPoolExecutor(0, 1,
 121                             KEEP_EXECUTOR_ALIVE_SECONDS, TimeUnit.SECONDS,
 122                             new LinkedBlockingQueue<>(), new BootstrapExecutors());
 123                 }
 124                 // The executor service will be elligible for gc
 125                 // KEEP_EXECUTOR_ALIVE_SECONDS seconds (30s)
 126                 // after the execution of its last pending task.
 127                 executorRef = new WeakReference<>(executor);
 128                 return executorRef.get();
 129             }
 130         }
 131 
 132         @Override
 133         public Thread newThread(Runnable r) {
 134             ExecutorService owner = getExecutor();
 135             Thread thread = AccessController.doPrivileged(new PrivilegedAction<Thread>() {
 136                 @Override
 137                 public Thread run() {
 138                     Thread t = InnocuousThread.newThread(new BootstrapMessageLoggerTask(owner, r));
 139                     t.setName("BootstrapMessageLoggerTask-"+t.getName());
 140                     return t;
 141                 }
 142             }, null, new RuntimePermission("enableContextClassLoaderOverride"));
 143             thread.setDaemon(true);
 144             return thread;
 145         }
 146 
 147         static void submit(Runnable r) {
 148             getExecutor().execute(r);
 149         }
 150 
 151         // This is used by tests.
 152         static void join(Runnable r) {
 153             try {
 154                 getExecutor().submit(r).get();
 155             } catch (InterruptedException | ExecutionException ex) {
 156                 // should not happen
 157                 throw new RuntimeException(ex);
 158             }


< prev index next >