But the synchronization/locking comes into picture if we create threads. right?
Yeah, but again you take lock on the object or say make your code block synchronized so that at a time only one thread could access it.
Remember we are talking about one object versus multiple threads.
You see in this code there is only one runnable object and three thread t1, t2 and t3 that will work on the same runnable object "r". At a time only one of the threads could acquire lock of "this" ("r" in main).
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop