Shouvik Bhattacharya wrote:Ok....thanks mate ..but I think even in the second example things are synchronizing on the same object.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Shouvik Bhattacharya wrote:I was kinda under the illusion that static is to Class Lock and instance is to Object Lock...
well things can be taken that way but now I feel that if the context demands thread safety of your instance then its the instance under consideration upon which appropriate synchronization efforts should be carried out in order to protect instance related state and on similar grounds when talking about Class properties or in other words the static guys the context demands synchronization efforts on the Class to be made. In short we can say that there is a lock available its up to the developer to make sure that he understands the contexts needs and codes accordingly. Hopefully I have understood.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Sounds about right, but you don't have to use:
synchronized(Object)
in either case.
Don't get me started about those stupid light bulbs. |