It can also result in one program dominating the system and preventing any other events from being processed. In single-threaded environment, when a thread blocks because it is waiting for some resource, the entire program stops running. One thread can pause without stopping other parts of your program. Threads can be in several states like running, ready, suspended, blocked, resumed. Thread priorities Java assigns to each thread a priority that determines how that thread should be treated with respect to others.
Priorities are integer values.
Instead, a priority is used to determine when to switch from one running thread to the next. This is called context-switch. That is, you must prevent one thread from writing data while the other thread is in the middle of reading it. You can think of a monitor as a very small box that can hold only one thread. Once a thread enters a monitor, all other threads must wait until that thread exits the monitor.