This is exactly the same exampl given in K & B book.
When I run this program with out synchronising the method , Fred and Lucy take turns in an irregular
pattern (as expected)
But when I run this program with the keyword Synchronised exactly as mentioned in the above code - I donot see them taking turns.
Fred makes 5 transacation in a sequence till there is no Balance left.
Then Lucy makes the next five transaction in a sequence which gives the output "Not enough moeny for Lucy to withdraw 0" 5 times in a sequence.
It looks like when I donot synchronise the method , both the threads are woking simultaneously but when I Synchronize the method, the second
thread only starts when the first thread is completed.
Is this how it is supposed to work ???