This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Green threads and multiple processors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Green threads and multiple processors" Watch "Green threads and multiple processors" New topic
Author

Green threads and multiple processors

Michael Hildner
Ranch Hand

Joined: Oct 13, 2000
Posts: 297
I think I remember reading somewhere that green threads can not take advantage of multiple processors. This is on a Sun box. Is this true?
Jim Baiter
Ranch Hand

Joined: Jan 05, 2001
Posts: 532
Native threads generally map to either a native OS/System thread or LightWeight Process. This means that when you create a new thread in Java, you get a new OS thread. In the case of Green threads, java creates and manages it's own virtual threads which don't have a corresponding OS thread. In this case Java and the application(s) it's running all effectively run in a single OS thread. So you're right, they won't take advantage of parallelism.
tom Su
Greenhorn

Joined: May 05, 2001
Posts: 7
care to explain. what is a Green thread?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521


Green threads appear to be an artifact of the original Green Project, which was trying to design a hand-held computer based on the Sparc chip. So the original Java (the called "Oak") VM was written to run directly on the Sparc, without Solaris/SunOS. Because of that, they had to roll their own
thread support. The project to transform Oak into Java had very limited resources initially, they only did the bare minimum to port the language to desktop computers (as anyone who ever used the 1.0 AWT can attest). So they kept Green threads in the Solaris version because it worked, kind of.
The Green threads implementation used all kinds of tricks to make sure that I/O never blocked the single native thread. When these tricks failed, the VM would hang until the I/O request completed.
BTW, it turns out that a one-to-one mapping of VM to native threads isn't optimal either, because native threads tend to have quite a bit of overhead. The current production release of the Solaris VM uses multiple native threads, with each native thread servicing a number of VM threads.
John Brewer
Jera Design

From:
http://www.mail-archive.com/advanced-java@xcf.berkeley.edu/msg04550.html
This is a Solaris discussion:
http://godzilla.cs.nwu.edu/info/java/tooldocs/solaris/threads.html


"JavaRanch, where the deer and the Certified play" - David O'Meara
Sanjay Deshpande
Ranch Hand

Joined: May 22, 2001
Posts: 111
HI ,
COULD ANY ONE PLEASE LEMME KNOW ANY LINK THAT 'LL GIVE COMPLETE INFO ON GREEN THREAD ??
ANY WHERE ON NET ...
PLEASE LEMME KNOW....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Green threads and multiple processors
 
Similar Threads
Synchronization across diff JVM
what is meant by "application doesnt work on 'green thread' jvm"?
Problem with Program on Dual processor
Green Thread
Native versus Greed