Static and dynamic methods

Source: Internet
Author: User

Static Methods occupy a large amount of memory, fast speed, less memory for dynamic points, and slow speed ..

However, the Web is multi-threaded. If you call a static method, You need to lock it. This will slow down the call.
Multithreading. In principle, static members need to be protected. Any static member may be conflicted by multiple threads.

 

Thread locking

The synchronization method is set to avoid (possibly) the same resource

Cross-access between multiple threads in a process. Set settestlist () as the synchronization method, Program Executive

When the row is in the test. settestlist (list) method, it should be a thread Security But test. Star

T () method calling may cause thread safety: 1. If start () is used for S of the test object

The ettestlist () method does not enable other threads and calls the settestlist () method. The current process is in

Thread security status 2. If

Start () enables other threads for the test object, calls the settestlist () method, and opens the line

The number of threads is greater than 1, and the current process is in the thread unsafe state. Obviously, when the thread is not secure, add the Method

The synchronized keyword has a meaning.

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.