Thread Context class loader analysis and implementation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.