Ishan Pandya wrote:can someone please explain me this code.. how can synchornized methods is executed by both the threads.. output is 5 ,4, 3 ,2, 1..
cant understand the flow of the code.. 
First, the output can not be "5,4,3,2,1..". You don't print out any commas, and you do printout
thread ids, names, and new lines. Giving us incorrect or summarized output is worse than giving no output since it specifically changes observed behavior. And you seem to be asking about observed behavior.
Why can two threads access the synchronized method? You have two instances of the Hold object. When you create a synchronized method you synchronize on the instance, since you have more than one instance you have more than one lock and more than one thread can run. If you want to prevent interleaved execution you need to synchronize on an object which is shared between all the threads.