How does Java achieve synchronization? Given an class with Synchronized method A and B, a normal method C, there are 2 threads, one instance, can these two threads call A at the same time? call A and B at the same time? A & C at the same time?
A&C yes, others no, java create instance on the heap which is shared by all threads, A and B can access the same shared resource, so at one time only one function can be executed. One instance is shared resource
Showing posts with label synchronization. Show all posts
Showing posts with label synchronization. Show all posts
Subscribe to:
Posts (Atom)