Convenience Thread factory that ensure threads are
created without referencing any web application ClassLoader.
Up to Java 17, the Thread constructor was taking a
snapshot of the calling context, which may contain a ProtectionDomain
that references a web application ClassLoader
(for example if the creation of the Thread was triggered
by some operation performed by the web application).
The Thread might then be pooled and prevent the
web application ClassLoader to be garbage collected
when the web application is undeployed.
For this reason, Threads must be created in a privileged
action, which restricts the calling context to just the caller
frame, not all the frames in the stack.
Since Java 18 and the removal of the Java security manager
and related classes by JEP 411, Threads do not retain
the calling context, so there is no need to create them in a
privileged action.
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static <T extends Thread> T |
| PrivilegedThreadFactory | back to summary |
|---|---|
| private PrivilegedThreadFactory() | |
| newThread | back to summary |
|---|---|
| pack-priv static <T extends Thread> T newThread(PrivilegedAction<T> creator) Creates a new
| |