In Java an Object itself can act as a lock for guarding its own state . This convention is used in many built in classes like Vector and other synchronized collections where every method is synchronized and thus guarded by the intrinsic lock of the object itself . Is this good or bad ? Please give reasons also .
Share
Pros
Cons
For the most part, it doesn’t matter unless you are developing an API which will be widely used. So while using
synchronised(this)is not ideal, it is simple.