I am new to Java, and was reading synchronized blocks stuff. I got confused in one of the statement, that during the static class the synchronization uses class instance and normal class uses current object for locking.
Now when both the classes are same, the only difference is that one class is static and other one is normal. Does this make any changes to the interpretation.
Then again my next question will be that in how many ways we can achieve synchronization.
Thanks
It’s not about classes — it’s about methods.
synchronizedmethods are synchronized on the instance;staticones have no instance, so the synchronization is performed on the correspondingClassinstance.