Stephan van Hulst wrote:Synchronizing a method acts as if the entire method body is a synchronized block, locking on the current object.
Winston Gutkowski wrote:If you use javadoc (and if you don't, I suggest you start ) the fact that a method is synchronized will show up in its documentation, so everybody will know that you only intended it to be run by one thread at a time.
Stephan van Hulst wrote:[It's important to note that this is an implementation detail. I'm actually not sure why they chose to include it in the JavaDoc. If a class or method is safe to use by multiple threads, it should be explicitly documented.
Winston Gutkowski wrote:I disagree. Why or how an object or method is synchronized is an implementation detail, but that it is is not.
And what's more explicit than showing the method signature?
Md. Hasibuzzaman Chowdhury wrote:Does the Synchronized Block Lock on the Object or just lock on the method/variable only , so that other member method/variables can be used at the same time, Or It also Block on the Object as Lock Synchronized method ?
Stephan van Hulst wrote:The synchronized keyword is not part of the method signature.
Thread safety is the that. synchronized is the how.
Md. Hasibuzzaman Chowdhury wrote:I know that Synchronized method Lock on the Object when called. But confusion about synchronized Block , if we call a member method/variable of a normal class from a Synchronized Block , Does the Synchronized Block Lock on the Object or just lock on the method/variable only , so that other member method/variables can be used at the same time, Or It also Block on the Object as Lock Synchronized method ?
Winston Gutkowski wrote:OK, method declaration then - ie, what javadoc shows you. Are you saying it shouldn't show that at all, or that it should pick and choose what it does?
OK again; but back in the days before ReentrantLocks, it used to be (basically) the only "how". And what are you going to say in any explicit documentation that isn't conveyed by the word 'synchronized'?
Stephan van Hulst wrote:Actually, I just read somewhere that since javadoc 1.2, the synchronized keyword doesn't show up anymore.
Md. Hasibuzzaman Chowdhury wrote:Thank you very much all of you for helping me specially to Winston Gutkowski, I get my answer from Winston reply.