Package org.eclipse.jetty.util.thread
Class PrivilegedThreadFactory
- java.lang.Object
-
- org.eclipse.jetty.util.thread.PrivilegedThreadFactory
-
class PrivilegedThreadFactory extends java.lang.Object
Convenience class to ensure that a new Thread is created inside a privileged block. This prevents the Thread constructor from pinning the caller's context classloader. This happens when the Thread constructor takes a snapshot of the current calling context - which contains ProtectionDomains that may reference the context classloader - and remembers it for the lifetime of the Thread.
-
-
Constructor Summary
Constructors Constructor Description PrivilegedThreadFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static <T extends java.lang.Thread>
TnewThread(java.util.function.Supplier<T> newThreadSupplier)
Use a Supplier to make a new thread, calling it within a privileged block to prevent classloader pinning.
-
-
-
Method Detail
-
newThread
static <T extends java.lang.Thread> T newThread(java.util.function.Supplier<T> newThreadSupplier)
Use a Supplier to make a new thread, calling it within a privileged block to prevent classloader pinning.- Parameters:
newThreadSupplier
- a Supplier to create a fresh thread- Returns:
- a new thread, protected from classloader pinning.
-
-