how can conventional locks protect the application from parallel access in java?

…4 threads…take a lock at the LITERALLY same time…

Can’t happen. Any “synchronized” operation (e.g., “take a lock”) must operate on the system’s main memory, and in any conventional computer system, there is only one memory bus. It is physically impossible for more than one CPU to access the main memory at the same time.

If two CPUs decide to access the memory at literally the same time, the hardware guarantees that one of them will “win” the race and go first, while the other one is forced to wait its turn.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top