Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Thread scheduling algorithm in java

  • Please log in to reply
1 reply to this topic

#1 radhika12


  • Members
  • 9 posts
  • Local time:03:27 AM

Posted 02 January 2015 - 11:41 PM

I just wanted to ask that if the threads are assigned priority to it by the JVM , then actually is priority scheduling algorithm used for the execution of the threads then does it not lead to starvation?


Also is it that it depends on the scheduling algo used by the Operating system for execution of threads ,and if it depends on Operating Systems and then there may be  a case that the operating system may be implementing different scheduling algorithm   then is the mixed combination of priority scheduling and the algorithm used by the operating system for execution of threads?

Edited by radhika12, 02 January 2015 - 11:55 PM.

BC AdBot (Login to Remove)


#2 Billy O'Neal

Billy O'Neal

    Visual C++ STL Maintainer

  • Malware Response Team
  • 12,304 posts
  • Gender:Male
  • Location:Redmond, Washington
  • Local time:02:57 PM

Posted 04 January 2015 - 10:27 PM

The JVM has no control over thread scheduling -- it could schedule its own sort of user-defined threads on top of the underlying machine's threads, but it can't make up scheduling behavior out of the ether. If the underlying platform schedules threads some way, that's how your threads will be scheduled.

A correct parallel algorithm must not induce thread starvation ("deadlocks"), and good algorithms will distribute the work over threads in an even fashion, regardless of how threads are scheduled. Even if this isn't necessary to keep the CPU cores busy, it is certainly necessary to keep threads from stepping on each others' cache lines and similar and incurring unnecessary cache coherency overhead.

If your program depends on how threads are scheduled, your program is broken. Fix it :)

Twitter - My statements do not establish the official position of Microsoft Corporation, and are my own personal opinion. (But you already knew that, right?)
Posted Image

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users