My question is regarding threads in general(ex: in Java).
The problem : when a thread is being in (Runnable - state) - i.e: it is executing, and it is giving an instruction (say by invoking the method addOneToX(int x)
), is it possible for the thread to quit or stop its work before finishing the instruction but after it has started executing it. in other words, most of instructions in high-level languages are decoded into the machine-specific language and decomposed to a number of machine-cycles (clock-cycles) in the CPU. So I guess it is clear, accordingly:
1> What is the minimum time given to a thread to be in the Runnable state?
2> How does the thread save its state so that it comes to it later? (i.e: when it quits Runnable state and comes back to it later to continue from where it stopped)