Synchronization problems occur when two threads have a access to the same object . In the following code :
In this we have two threads t1 and t2 . The common object they share is "r" . " r" has access to x ; thereby granting t1 and t2 access to x , leading to synchronization problems in the output .
i have the following doubts :
- is the above reasoning correct ?
- the objetc on which run() is executed is "r" and not t1 and t2?
And when we extend the
Thread class the run() is executed on the object of the subclass of Thread ? as in :
So here the run() is executed on ob?