Home » Java Thread setContextClassLoader() Method with Examples

Java Thread setContextClassLoader() Method with Examples

by Online Tutorials Library

Java Thread setContextClassLoader() method

The setContextClassLoader() method of thread class sets the context ClassLoader for the thread. The context ClassLoader can be set when a thread is created. It allows the creator of the thread to provide the appropriate class loader through getContextClassLoader to code running in the thread when loading classes and resources.

Syntax

Parameter

cl: It is the context ClassLoader for Thread

Return

It does not return any value.

Exception

SecurityException: If the current thread cannot set the context ClassLoader.

Example

Test it Now

Output:

Thread is running  Context ClassLoader = [email protected]  

You may also like