Java Thread getContextClassLoader() method

The getContextClassLoader() method of thread class returns the context ClassLoader for the thread.

Syntax

Return

It returns the context ClassLoader for the Thread.

Exception

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

Example

Test it Now

Output:

Context ClassLoader = jdk.internal.loader.ClassLoaders$AppClassLoader@7c53a9eb
Parent = jdk.internal.loader.ClassLoaders$PlatformClassLoader@ed17bee
Class = class jdk.internal.loader.ClassLoaders$AppClassLoader
Thread is running





Latest Courses