020 Threads for Comprehensive consideration

Source: Internet
Author: User

One. Overview

In the previous we introduced the thread synchronization and the way of communication, it is the thread concurrency is better to ensure the security of threads, visibility, order.

In general, it is the ability to minimize the uncontrollable nature of threads and to find a balance between correctness and performance.

Control means a decrease in performance, but we need control to ensure security.

In general, now is the time for us to find the balance point of the thread.

Two. Our expectations

For threads to say. We want to get a high-performance, results-efficient thread running.

But this is not possible. We always have to sacrifice some to do it. But that's not to say that there is nothing we can do about it, we could make a few improvements.

[1] Reducing the granularity of the lock, so there is a high-level lock in the Juc.

[2] No locking, using CAs to complete.

[3] The overall improvement of the concurrency scheme, the proposed thread helper class.

[4] Reduce the cost of thread creation, the emergence of a thread pool framework.

[5] Safe collection reduces synchronization costs

And so on, and so on, all of these things appear in the Juc. There are also callable,future asynchronous concepts such as the emergence of fork/join parallel concept.

With Juc, we can simplify the difficulty of writing concurrent programs, but we need to be aware that concurrency always needs to be treated with care.

020 Threads for Comprehensive consideration

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.