< prev index next >

src/java.base/share/classes/java/lang/ref/Reference.java

Print this page

290             } else {
291                 return false;
292             }
293         }
294     }
295 
296     /**
297      * Start the Reference Handler thread as a daemon thread.
298      */
299     static void startReferenceHandlerThread(ThreadGroup tg) {
300         Thread handler = new ReferenceHandler(tg, "Reference Handler");
301         /* If there were a special system-only priority greater than
302          * MAX_PRIORITY, it would be used here
303          */
304         handler.setPriority(Thread.MAX_PRIORITY);
305         handler.setDaemon(true);
306         handler.start();
307     }
308 
309     static {




310         // provide access in SharedSecrets
311         SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() {
312             @Override
313             public void startThreads() {
314                 ThreadGroup tg = Thread.currentThread().getThreadGroup();
315                 for (ThreadGroup tgn = tg;
316                      tgn != null;
317                      tg = tgn, tgn = tg.getParent());
318                 Reference.startReferenceHandlerThread(tg);
319                 Finalizer.startFinalizerThread(tg);
320             }
321 
322             @Override
323             public boolean waitForReferenceProcessing()
324                 throws InterruptedException
325             {
326                 return Reference.waitForReferenceProcessing();
327             }
328 
329             @Override

290             } else {
291                 return false;
292             }
293         }
294     }
295 
296     /**
297      * Start the Reference Handler thread as a daemon thread.
298      */
299     static void startReferenceHandlerThread(ThreadGroup tg) {
300         Thread handler = new ReferenceHandler(tg, "Reference Handler");
301         /* If there were a special system-only priority greater than
302          * MAX_PRIORITY, it would be used here
303          */
304         handler.setPriority(Thread.MAX_PRIORITY);
305         handler.setDaemon(true);
306         handler.start();
307     }
308 
309     static {
310         runtimeSetup();
311     }
312 
313     private static void runtimeSetup() {
314         // provide access in SharedSecrets
315         SharedSecrets.setJavaLangRefAccess(new JavaLangRefAccess() {
316             @Override
317             public void startThreads() {
318                 ThreadGroup tg = Thread.currentThread().getThreadGroup();
319                 for (ThreadGroup tgn = tg;
320                      tgn != null;
321                      tg = tgn, tgn = tg.getParent());
322                 Reference.startReferenceHandlerThread(tg);
323                 Finalizer.startFinalizerThread(tg);
324             }
325 
326             @Override
327             public boolean waitForReferenceProcessing()
328                 throws InterruptedException
329             {
330                 return Reference.waitForReferenceProcessing();
331             }
332 
333             @Override
< prev index next >