After a thread enters a synchronized method on an object

Source: Internet
Author: User

After a thread enters a synchronized method on an object


In the following cases:


1. Whether the Synchronized keyword was added before other methods, if not added, it can.


2. If wait is called internally by this method, you can enter another synchronized method.


3. If all other methods add the Synchronized keyword and no wait is called internally, you cannot.


4. If the other method is static, it uses a synchronous lock that is the byte code of the current class and cannot be synchronized with a non-static method because the non-static method uses this.


When an object is passed as a parameter to a method, this method can change the properties of the object and return the changed result, is it a value pass or a reference pass?


is a value pass. The Java programming language has only value-passing parameters. When an object instance is passed as a parameter to a method, the value of the parameter is a reference to the object. The contents of the object can be changed in the called method, but the object's reference is never changed.



After a thread enters a synchronized method on an object

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.