that you can directly manipulate static member, whilst another thread owns lock on that class's "Class object".
...but how come acquiring lock on .class will synchronized System.out present in non static method.
Originally posted by Abdul Mohsin:
But in my case we are acquiring lock on .class and not on System.out, I agree that if we put lock on System.out then it will give correct results but how come acquiring lock on .class will synchronized System.out present in non static method.
Originally posted by Chandra Bhatt:
Did you consider the output from my code where I marked output as Line #1 and Line #2. I would like to get the reason for that sequence from you.