November 26, 2015 Java Basic Series (iii) Threadlocal class primary Learning

Source: Internet
Author: User

The Threadlocal class is designed to solve multi-threaded security issues. Thread safety means that each thread operates its own variables and does not affect the values of other threads.

In many cases, threadlocal is easier and more convenient than using the synchronized synchronization mechanism to solve thread safety problems, and results programs have higher concurrency.

1 threadlocal The idea of solving multithreading security is to control it through Threadlocalmap, just like there are multiple key-value pairs in a map, Threadlocalmap can be understood by comparing the map.

2 generally by overwriting Threadlocal's InitialValue () method on the line set

3 threadlocal Since the JDK1.2 began to appear, since 1.5 began to support generics.

Specific understanding, you can learn from the following blog, written in very detailed:

http://blog.csdn.net/lufeng20/article/details/24314381

November 26, 2015 Java Basic Series (iii) Threadlocal class primary Learning

Related Article

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.