Tips on multi-threaded writing--Thoughts on the video of Zhang Xiaoxiang podcast teacher

Source: Internet
Author: User

In this, really thank the Zhang Xiaoxiang podcast teacher, although has left, but still want to thank. Multithreading this piece helps a lot. (Watch a video of public lessons)

In general, I can write a single-threaded version of the program, but it is important to consider clearly, will be a race condition of the resources written into the same class.

Then consider if there is a race condition, then add synchronized if you need to keep synchronous communication with this.wait () and This.notify (), and so on, why use while because the thread may wake up, not be awakened, but wake up. You can judge it again with while. You can't use IF.

Then see if you can use the lock to further optimize, synchronous communication, the use of condition to optimize, the benefits of the lock can be read and write lock, this is really bad. Admire.

Tips on multi-threaded writing--Thoughts on the video of Zhang Xiaoxiang podcast teacher

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.