Online Library TheLib.net » Java Threads
cover of the book Java Threads

Ebook: Java Threads

00
27.01.2024
0
0
This book makes the following claims which as far as I can see are entirely baseless, for the reasons given:

> A Java virtual machine is required to implement a preemptive, priority-based scheduler

The word 'pre-emptive' does not appear in the JLS.

> The Java virtual machine never changes the priority of a thread, even if the thread has been running for a certain period of time

Can't find that anywhere either.

> the contract between the Java virtual machine and the underlying operating system is that the operating system must generally choose to run the Java thread with the highest priority

The 'contract' is between the Java code and the JVM, not the JVM and the O/S.

> That's what we mean when we say that Java implements a priority-based scheduler

Java isn't required to 'implement' a scheduler at all.

> This scheduler is implemented in a preemptive fashion, meaning that when a higher-priority thread comes along, that thread interrupts (preempts) whatever lower-priority thread is running at the time.

This appears nowhere in the JLS.

> The contract with the operating system, however, is not absolute, which means that the operating system can sometimes choose to run a lower-priority thread.

In other words it's +not+ pre-emptive. Make up your mind.

> Java's requirement for a priority-based, preemptive scheduling mechanism ...

Which is nowhere to be found.

> A Java thread can have one of 11 priorities

MIN_PRIORITY is 1, MAX_PRIORITY is 10: that makes 10, not 11.

> In fact, preemption means only that a higher-priority thread runs instead of a lower-priority one

No it doesn't. It means that when a higher-priority thread becomes ready it pre-empts the execution of any lower-priority threads that are currently executing regardless of time-slice etc. This is a feature of real-time systems that Java is +not+ required to implement.

This book cannot be recommended in the presence of these egregious errors. Doug Lea's book as recommended by other reviewers is the one to go for.
Download the book Java Threads for free or read online
Read Download
Continue reading on any device:
QR code
Last viewed books
Related books
Comments (0)
reload, if the code cannot be seen