Can someone please explain the difference between preemptive Threading model and Non Preemptive threading model?
As per my understanding:
- Non Preemptive threading model: Once a thread is started it cannot be stopped or the control cannot be transferred to other threads until the thread has completed its task.
- Preemptive Threading Model: The runtime is allowed to step in and hand control from one thread to another at any time. Higher priority threads are given precedence over Lower priority threads.
Can someone please:
- Explain if the understanding is correct.
- Explain the advantages and disadvantages of both models.
- An example of when to use what will be really helpful.
- If i create a thread in Linux (system v or Pthread) without mentioning any options(are there any??) by default the threading model used is preemptive threading model?