Originally posted by Prasun Howlader:
...although the fun method is synchronized the program does not produce desire result...
The first
thread that enters the synchronized run() method will keep the RunnableThread object's lock until it finishes looping and leaves the method.
But synchronizing the fun() method doesn't have an effect, because the fun() method just prints a single line. So
each time fun() is called, the Thread1 object's lock is acquired, a line is printed, and then the lock is immediately released again.