Java Concurrency Build Thread Safety Program (2)

Source: Internet
Author: User

We know that the root cause of thread safety is:

Multiple threads access a shared resource and make non-atomic modifications to the shared resource.

It is very complex and error-prone to find out which threads have access to the same resource in a large program. So when developing a thread-safe program, you encapsulate the shared resource and control the thread's access to it.

In Java, object-oriented provides a way to encapsulate and access internal resources, through the face object, not only can write out the structure elegant, high maintainability class, but also help to write thread security class.

encapsulates and controls access to shared resources in Java through object-oriented technology .

Using object-oriented not only makes it easy to encapsulate and control shared resources, but it is also easy to build multiple packages of shared resources. A thread-safe class that builds multiple shared resources through multiple thread-safe classes is much easier to consider in one program than to control multiple shared resources.

Thread- safe programs that make it easier to write complex multi-shared resources through the thread-safety class combination .

Java Concurrency Build Thread Safety Program (2)

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.