Tell you with your personal experience that in your concurrent program code block, it is best not to have a reference type.

Source: Internet
Author: User

Tell you with your personal experience that in your concurrent program code block, it is best not to have a reference type.

I will tell you through my personal experience that in your concurrent program code block, it is best not to have a reference type, and the necessary string type is still acceptable.
At present, I am putting the concurrent programs I wrote some time ago into my project to improve the speed. Because my project is connected to mobile, after asking whether the mobile interface can respond to high concurrency and getting a positive response, I started to design the demo, but there were always errors and problems. Later I thought, this may be a problem with the reference type, because my concurrent code needs to constantly assign values to a field of a class instance object and then call the Mobile Interface, I will be wondering, it may be because the concurrency is too fast, and the memory address is not changed after the reference type value is assigned, because the class instance object is global, later, I changed it to a local one. Is it too big to change the memory? I prefer speed and speed, and sure enough! Running successful, no error.
Finally, I figured out that the value type in concurrency is the safest. Of course, sometimes we still need a string. In this case, we 'd better make the string a local variable, and the rest of the reference types are also, we can think of the reference parameter required for a concurrent request as a request. The big deal is that each request Call uses a local variable and consumes much memory. Besides, we can also manually release the memory ourselves!

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.