Could someone explain two me why these to codes dont output the same results (the only difference between two codes is in the run() method) ?
NB: the first code seem
When you want to synchronize two threads you must lock on a shared resource by all threads. Synchronizing in the run method(or any instance method in thread class) each thread locks it's own method resulting no synchronization at all.