• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Book about what the JVM does with threads

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 23901
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
 
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does that mean a multithreaded application will behave differently on the OS'es you mentioned above?
 
Ranch Hand
Posts: 111
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How threads interact is described in Java Memory Model. You can read the JMM specification or 'Java Concurrency in Practice' book.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 once met a man from Nantucket. He had a tiny ad
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic