Originally Posted by Fou-Lu
a1 and a2 are running through b1 and b2. These are threads of their own, so you are not doing anything to block the other objects, so issuing a sleep on that running thread won't impact another thread. There are many ways to do this from the simple implicit locks of the object, to running with ExecutorService and pools or writing your own threads and runnables. But you'll need to write the blocking conditions for the thread.
I think u got it wrong...My question was that if a synchronized method is called by a thread then it should not allow its control to other threads until it releases control for the 1st thread....
I guess when a synchronized method is called by the same reference for the 2nd time then it serializes it(blocks it until the first call returns control)...In the above case, I have used different references(a1 and a2) and although they call the same method they are allow concurrent access without synchronization.
Correct if I am wrong