Thread scheduling in java

radha gogia

radha gogia

@radha-BTDzli • Oct 24, 2024
I just want to ask that if the scheduling algorithm by JRE is priority scheduling since the threads are executed on the basis of their priority ,then is time slicing also made for the execution of threads because because of execution on the basis of priority may lead to starvation ,so I have confusion that is round robin scheduling algorithm implemented but as far as I know round robin scheduling has nothing to do with priority of threads since each thread is excecuted depending on the time slot.

So ,a lot of confusion in this case.

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • rahul69

    rahul69

    @rahul69-97fAOs Jan 5, 2015

    radha gogia
    I just want to ask that if the scheduling algorithm by JRE is priority scheduling since the threads are executed on the basis of their priority ,then is time slicing also made for the execution of threads because because of execution on the basis of priority may lead to starvation ,so I have confusion that is round robin scheduling algorithm implemented but as far as I know round robin scheduling has nothing to do with priority of threads since each thread is excecuted depending on the time slot.

    So ,a lot of confusion in this case.
    Don't get confused 😀
    It's simple:
    *JRE uses preemptive priority scheduling.
    *Also round robin scheduling is a type of preemptive scheduling.
    Scheduling is of two types: non preemptive (jobs run until completion) and preemptive (jobs can be force quit to give chance to others).
    Since both starred algo's given above are preemptive, both can rotate jobs, without jobs being fully completed, one considers priority also while preempting, while other(ie round robin) gives same priority to all jobs while preempting.
    Hope it clears a bit, 😀