In the last "https://www.cnblogs.com/webor2006/p/9246850.html" analysis source found two places to set the thread context ClassLoader code, as follows:
Because it is a very important thing, so this time specifically for it to carry out the theme, the main role in order to change the principal and parental mode in some scenarios is not suitable or can not meet the needs, the following first write a simple test code:
What is the output?
That is, the context class loader for the current thread is the application ClassLoader, and the second output null is not surprising, because thread is the system class in the JDK and of course it is loaded by the startup ClassLoader.
For the above example there is a preliminary understanding of the first, in the formal introduction of the thread of the context class loader need to introduce some theoretical things, only to understand its background so as to better grasp it, as follows:
- Current ClassLoader: Each class uses its own class loader (which loads its own classloader) to load other classes (referring to the classes they depend on).
Thread Context class loader analysis and implementation