Differences between static and non-static methods in the Java language for synchronized adornments

Source: Internet
Author: User

Synchronized locks the object, and when the object is initialized, the JVM calls the block of statements outside the method before the object is initialized, and the object does not exist, so there is no lock.

So what's the difference between static and non-static methods before adding synchronized?

As we all know, the static method belongs to the class method, it belongs to this class (note: The class here is not a specific object of Class), then static acquires the lock,
is the class (class) of the object that is currently calling this method, and is no longer a specific object produced by this class.
Instead of the lock acquired by the static method, it is the lock of the object that is currently calling this method. Therefore, they do not create mutual exclusion.

http://blog.csdn.net/virgoboy2004/article/details/7585182

Differences between static and non-static methods in the Java language for synchronized decoration (RPM)

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.