< prev index next >

src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java

Print this page

1460         try {
1461             while (runStateLessThan(ctl.get(), TERMINATED)) {
1462                 if (nanos <= 0L)
1463                     return false;
1464                 nanos = termination.awaitNanos(nanos);
1465             }
1466             return true;
1467         } finally {
1468             mainLock.unlock();
1469         }
1470     }
1471 
1472     // Override without "throws Throwable" for compatibility with subclasses
1473     // whose finalize method invokes super.finalize() (as is recommended).
1474     // Before JDK 11, finalize() had a non-empty method body.
1475 
1476     /**
1477      * @implNote Previous versions of this class had a finalize method
1478      * that shut down this executor, but in this version, finalize
1479      * does nothing.




1480      */
1481     @Deprecated(since="9")

1482     protected void finalize() {}
1483 
1484     /**
1485      * Sets the thread factory used to create new threads.
1486      *
1487      * @param threadFactory the new thread factory
1488      * @throws NullPointerException if threadFactory is null
1489      * @see #getThreadFactory
1490      */
1491     public void setThreadFactory(ThreadFactory threadFactory) {
1492         if (threadFactory == null)
1493             throw new NullPointerException();
1494         this.threadFactory = threadFactory;
1495     }
1496 
1497     /**
1498      * Returns the thread factory used to create new threads.
1499      *
1500      * @return the current thread factory
1501      * @see #setThreadFactory(ThreadFactory)

1460         try {
1461             while (runStateLessThan(ctl.get(), TERMINATED)) {
1462                 if (nanos <= 0L)
1463                     return false;
1464                 nanos = termination.awaitNanos(nanos);
1465             }
1466             return true;
1467         } finally {
1468             mainLock.unlock();
1469         }
1470     }
1471 
1472     // Override without "throws Throwable" for compatibility with subclasses
1473     // whose finalize method invokes super.finalize() (as is recommended).
1474     // Before JDK 11, finalize() had a non-empty method body.
1475 
1476     /**
1477      * @implNote Previous versions of this class had a finalize method
1478      * that shut down this executor, but in this version, finalize
1479      * does nothing.
1480      * 
1481      * @deprecated Finalization has been deprecated for removal.  See
1482      * {@link java.lang.Object#finalize} for background information and details
1483      * about migration options.
1484      */
1485     @Deprecated(since="9", forRemoval=true)
1486     @SuppressWarnings("removal")
1487     protected void finalize() {}
1488 
1489     /**
1490      * Sets the thread factory used to create new threads.
1491      *
1492      * @param threadFactory the new thread factory
1493      * @throws NullPointerException if threadFactory is null
1494      * @see #getThreadFactory
1495      */
1496     public void setThreadFactory(ThreadFactory threadFactory) {
1497         if (threadFactory == null)
1498             throw new NullPointerException();
1499         this.threadFactory = threadFactory;
1500     }
1501 
1502     /**
1503      * Returns the thread factory used to create new threads.
1504      *
1505      * @return the current thread factory
1506      * @see #setThreadFactory(ThreadFactory)
< prev index next >