F
failure_to
Hello
I'm currently learning about threads and there are few things
confusing about it
1)
If I understand it correctly, then in multithreaded program JVM
obtains threads from the pool and manages which thread is run on CPU
based on one of the two models:
a) Cooperative threading model
* here thread currently running voluntarily gives up control of the
CPU ¡K thus if this running thread ¡§wanted ¡§, it could very well never
give up the control of CPU?!
* I¡¦m assuming thread priorities have no meaning when cooperative
threading model is used?
* Since it is a job of thread scheduler to decide which thread will
run and how much time it will have „³ Thus what is its purpose when
cooperative threading model is applied ( since here thread priorities
have no meaning )?
or
b) Preemptive threading model:
* Here OS interrupts threads after period of time?
* Also, threads with higher priority can preempt lover priority
threads ( assuming preempt means that lover thread is already running
when higher priority thread decides it wants to run )?!
* But even highest priority thread will only have so much time before
the scheduler gives control ( even if just for a brief period of
time ) to lover level priority thread?
2)
Is JVM always the one that manages thread movement ( by thread
movement I mean deciding which thread to allow to run ), or are there
OSs that either:
a) won¡¦t allow JVM to take control of managing threads?
b) or some JVM version for particular OS allows this OS to do the job
of thread movement instead of JVM?
c) What kind of thread movement model do these OSs usually employ?
thank you
I'm currently learning about threads and there are few things
confusing about it
1)
If I understand it correctly, then in multithreaded program JVM
obtains threads from the pool and manages which thread is run on CPU
based on one of the two models:
a) Cooperative threading model
* here thread currently running voluntarily gives up control of the
CPU ¡K thus if this running thread ¡§wanted ¡§, it could very well never
give up the control of CPU?!
* I¡¦m assuming thread priorities have no meaning when cooperative
threading model is used?
* Since it is a job of thread scheduler to decide which thread will
run and how much time it will have „³ Thus what is its purpose when
cooperative threading model is applied ( since here thread priorities
have no meaning )?
or
b) Preemptive threading model:
* Here OS interrupts threads after period of time?
* Also, threads with higher priority can preempt lover priority
threads ( assuming preempt means that lover thread is already running
when higher priority thread decides it wants to run )?!
* But even highest priority thread will only have so much time before
the scheduler gives control ( even if just for a brief period of
time ) to lover level priority thread?
2)
Is JVM always the one that manages thread movement ( by thread
movement I mean deciding which thread to allow to run ), or are there
OSs that either:
a) won¡¦t allow JVM to take control of managing threads?
b) or some JVM version for particular OS allows this OS to do the job
of thread movement instead of JVM?
c) What kind of thread movement model do these OSs usually employ?
thank you