Top Description Fields Constructors Methods
org.apache.poi.util

public Class ThreadLocalUtil

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List

Small utility to allow to remove references held in ThreadLocals. This is sometimes necessary, e.g. when returning threads into a global thread pool. For each usage of ThreadLocal, a cleaner is registered via registerCleaner().

Field Summary

Modifier and TypeField and Description
private static final List<Runnable>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
clearAllThreadLocals()

Clear ThreadLocals of the current thread.

public static void
registerCleaner(Runnable
a runnable which clears some thread-local that is located outside of the "poi" module.
cleaner
)

Intended for internal use only so other modules of Apache POi can add cleaners.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

registeredCleanersback to summary
private static final List<Runnable> registeredCleaners

Constructor Detail

ThreadLocalUtilback to summary
private ThreadLocalUtil()

Method Detail

clearAllThreadLocalsback to summary
public static void clearAllThreadLocals()

Clear ThreadLocals of the current thread. This can be used to clean out a thread before "returning" it to a thread-pool or a Web-Container like Tomcat. Usually org.apache.xmlbeans.ThreadLocalUtil#clearAllThreadLocals() should be called as well to clear out some more ThreadLocals which are created by the XMLBeans library internally.

registerCleanerback to summary
public static void registerCleaner(Runnable cleaner)

Intended for internal use only so other modules of Apache POi can add cleaners.

Parameters
cleaner:Runnable

a runnable which clears some thread-local that is located outside of the "poi" module.

Annotations
@Internal