mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8193300: Miscellaneous changes imported from jsr166 CVS 2018-01
Reviewed-by: martin
This commit is contained in:
parent
c19d18871c
commit
d771fc3a6b
149 changed files with 872 additions and 571 deletions
|
@ -264,13 +264,12 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||
* assist in storage reclamation when large numbers of queued tasks
|
||||
* become cancelled.</dd>
|
||||
*
|
||||
* <dt>Finalization</dt>
|
||||
* <dt>Reclamation</dt>
|
||||
*
|
||||
* <dd>A pool that is no longer referenced in a program <em>AND</em>
|
||||
* has no remaining threads will be {@code shutdown} automatically. If
|
||||
* you would like to ensure that unreferenced pools are reclaimed even
|
||||
* if users forget to call {@link #shutdown}, then you must arrange
|
||||
* that unused threads eventually die, by setting appropriate
|
||||
* has no remaining threads may be reclaimed (garbage collected)
|
||||
* without being explicity shutdown. You can configure a pool to allow
|
||||
* all unused threads to eventually die by setting appropriate
|
||||
* keep-alive times, using a lower bound of zero core threads and/or
|
||||
* setting {@link #allowCoreThreadTimeOut(boolean)}. </dd>
|
||||
*
|
||||
|
@ -361,7 +360,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
* time, but need not hit each state. The transitions are:
|
||||
*
|
||||
* RUNNING -> SHUTDOWN
|
||||
* On invocation of shutdown(), perhaps implicitly in finalize()
|
||||
* On invocation of shutdown()
|
||||
* (RUNNING or SHUTDOWN) -> STOP
|
||||
* On invocation of shutdownNow()
|
||||
* SHUTDOWN -> TIDYING
|
||||
|
@ -581,9 +580,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
private static final RuntimePermission shutdownPerm =
|
||||
new RuntimePermission("modifyThread");
|
||||
|
||||
/** The context to be used when executing the finalizer, or null. */
|
||||
private final AccessControlContext acc;
|
||||
|
||||
/**
|
||||
* Class Worker mainly maintains interrupt control state for
|
||||
* threads running tasks, along with other minor bookkeeping.
|
||||
|
@ -1300,9 +1296,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
throw new IllegalArgumentException();
|
||||
if (workQueue == null || threadFactory == null || handler == null)
|
||||
throw new NullPointerException();
|
||||
this.acc = (System.getSecurityManager() == null)
|
||||
? null
|
||||
: AccessController.getContext();
|
||||
this.corePoolSize = corePoolSize;
|
||||
this.maximumPoolSize = maximumPoolSize;
|
||||
this.workQueue = workQueue;
|
||||
|
@ -1469,33 +1462,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes {@code shutdown} when this executor is no longer
|
||||
* referenced and it has no threads.
|
||||
*
|
||||
* <p>This method is invoked with privileges that are restricted by
|
||||
* the security context of the caller that invokes the constructor.
|
||||
*
|
||||
* @deprecated The {@code finalize} method has been deprecated.
|
||||
* Subclasses that override {@code finalize} in order to perform cleanup
|
||||
* should be modified to use alternative cleanup mechanisms and
|
||||
* to remove the overriding {@code finalize} method.
|
||||
* When overriding the {@code finalize} method, its implementation must explicitly
|
||||
* ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
|
||||
* See the specification for {@link Object#finalize()} for further
|
||||
* information about migration options.
|
||||
*/
|
||||
@Deprecated(since="9")
|
||||
protected void finalize() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm == null || acc == null) {
|
||||
shutdown();
|
||||
} else {
|
||||
PrivilegedAction<Void> pa = () -> { shutdown(); return null; };
|
||||
AccessController.doPrivileged(pa, acc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the thread factory used to create new threads.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue