Java multithreaded Programming (ii) Concurrent access to objects and variables

Source: Internet
Author: User
Tags volatile

One, synchronized synchronization method

1. The variables within the method are thread-safe

2. Instance variables non-thread safe

3. Multiple Objects multiple locks

4.synchronized method and Lock object

5. Dirty Reading

6.synchronized Lock Punch in

7. Abnormal, lock automatic release

8. Synchronization does not have inheritance

Second, synchronized synchronous statement block

Disadvantages of the 1.synchronized approach

Use of 2.synchronized synchronous code blocks

3. Use synchronous code block to solve the disadvantage of synchronization

4. Half asynchronous, half synchronous

Synchronization between 5.synchronized code blocks

6. Verify that the synchronization synchronized (this) code block is locking the current object

7. Use any object as a monitor

8.3 Conclusions of refinement verification

9. Static sync synchronized and synchronized (this) code block

10. Constant pool properties for data type string

11. Synchronous Synchronized method infinite wait and solve

12. Multi-threaded deadlock

13. Built-in classes and static built-in classes

14. Built-in classes and synchronization: Experiment 1

15. Built-in classes and synchronization: Experiment 2

16. Change of lock Object

Third, the volatile keyword

1. Keyword volatile and dead loop

2. Resolve the synchronization cycle

3. Resolving Asynchronous Dead Loops

4.volatile Non-atomic properties

5. Using atomic classes for i++ operations

6. Atomic classes are not completely safe.

7.synchronized code block with volatile sync function

Java multithreaded Programming (ii) Concurrent access to objects and variables

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.