What is the mechanism of Thread Priority & Thread Scheduler? How do Threads with various priority levels behave in time-sliced and non-time-sliced environments?
Created May 4, 2012
To answer your second question, I think you are referring to green threads and native threads. Green Threads is the cooperative thread model where the JVM handles the scheduling of threads. Native Threads is the preemptive threading model which use the OS to schedule threads. In the Green Thread model, threads only give up control if they call yield(), sleep() or make a blocking IO call. Under the Native Thread model, you never know when your thread is going to be interrupted and must code accordingly, using synchronized statements. Unless you target your code to a particular platform, you need to code such that it behaves in a cooperative as well as a preemptive environment.