
7.24 Errors and Exceptions in Java and Multithreaded Programming
7.15 Synchronization
When multiple threads act on different objects, we would call it multitasking. As per priori-
ties allocated and as per the CPU scheduling, threads execute different objects and produce
results. There is no problem in this case.
Suppose multiple threads act on the same object? Then it can lead to problems. Let us
say that there are two threads, thread 1 and thread 2, acting on the object, that is,
they will concurrently execute the same run() command. Each thread has only one job,
that of incrementing the counter and send it to the printer for printing. The output ...