This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Book about what the JVM does with threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Book about what the JVM does with threads" Watch "Book about what the JVM does with threads" New topic
Author

Book about what the JVM does with threads

Vinicius Munhoz
Greenhorn

Joined: Jan 28, 2010
Posts: 1
Hello!

Please i'm doing a final paper for the university and i need a book that explains about how the JVM manages the threads.
any one can recomend me a nice book about it?


Thank you,
Vinícius


SCJP
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18138
    
  39



Basically, all modern JVMs will delegate the threading tasks to the underlying threading system. For Linux, it will be the POSIX threading API. For Solaris, it will be Solaris threads. And for Windows, obviously, it will be the Windows threading system. This means that the behavior is passed down to the underlying operating system (and the user level library code) -- scheduling, priority levels mapping, support for priority inheritance, etc. etc. etc.

So... there isn't a single answer to your question. How the JVM manages threads is, hence, implementation specific.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Vedhas Pitkar
Ranch Hand

Joined: Jan 27, 2001
Posts: 445
Does that mean a multithreaded application will behave differently on the OS'es you mentioned above?
Istvan Kovacs
Ranch Hand

Joined: May 06, 2010
Posts: 100
Vedhas Pitkar wrote:Does that mean a multithreaded application will behave differently on the OS'es you mentioned above?


A correctly written multithreaded application will work well on all platforms. However, there are some mistakes that are easy to make, and bad code may work on one platform and not on another. For example, long assignment may be implemented as two separate 32-bit writes; depending on the VM and hardware, it may possible to read a half-written long (if no correct synchronization is used; everything will work on all platforms if properly synchronized).
Playing with thread priorities is another issue: Java thread priorities must be mapped to the thread priorities supported by the underlying OS. If you rely on priorities in scheduling, you'll end up with a fragile, OS-dependent program.

A good book is Java Concurrency in Practice.
aryan Sharma
Greenhorn

Joined: Oct 10, 2005
Posts: 27
you may want to look at the JVM spec to understand how exactly the threads are handled. you could use http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html for your reference.
Maris Orbidans
Ranch Hand

Joined: Mar 08, 2004
Posts: 149
How threads interact is described in Java Memory Model. You can read the JMM specification or 'Java Concurrency in Practice' book.
Vadym Ustymenko
Greenhorn

Joined: Jun 25, 2006
Posts: 5
Here is an article on how JVM manages resources shared in concurrent execution: http://javatip.com/2010/07/core-java/concurrency/thread-safe-without-synchronization/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Book about what the JVM does with threads
 
Similar Threads
Questions about locks
To scott and Henry
This week's giveaway!
threads: time-sliced versus preemptive
what does daemon thread means?