File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes Multithreading in monoprocess OS 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 "Multithreading in monoprocess OS" Watch "Multithreading in monoprocess OS" New topic
Author

Multithreading in monoprocess OS

Kartik Patel
Ranch Hand

Joined: Sep 12, 2005
Posts: 73
Hi,
Can any one tell me that is it possible to run multithreaded java program in a non-multithreaded (mono process ) OS?
If yes, than what will be the difference of having underlying OS supporting multithreaded environment or monoprocess environment?


Chop your own wood, and it will warm you twice. - Henry Ford
Chris Beckey
Ranch Hand

Joined: Jun 09, 2006
Posts: 116

The really simple answer is .. yes. A more useful answer is to look very carefully at the documentation for the target JVM.
Whether the JVM uses OS threads or whether it implements its own threading is a function of the JVM. Most (maybe all) current JVMs use OS threads (or processes) but there were (still are?) some implementations that implement their own threading, perhaps because the OS does not support threads.
Now I'll go out on a limb ... OS threading implementations are faster than JVM implementations and scale better. Other than that you should not see a difference.

From an October, 2000 article ( http://java.sun.com/developer/technicalArticles/Programming/linux/) :

"One major difference between developing on Linux from other Unix operating systems is the system threads library. In Java 2 releases prior to 1.3, the Java virtual machine uses its own threads library, known as green threads, to implement threads in the Java platform. The advantage here is that green threads minimize the Java virtual machine's exposure to differences in the Linux threads library and makes the port easier to complete. The downside is that using green threads means system threads on Linux are not taken advantage of and so the Java virtual machine is not scalable when additional CPUs are added.

In Java 2 Release 1.3, the Hotspot virtual machine uses system threads to implement Java threads. Because Linux threads are implemented as a cloned process, each Java thread shows up in the process table if you run the ps command. This is normal behavior on Linux."
...
"By comparison, on Solaris the Java threads are mapped onto user threads, which in turn are run on Lightweight processes (LWP). On Windows the threads are created inside the process itself. For this reason, creating a large number of Java threads on Solaris and Windows today is faster than on Linux. This means you might need to adjust programs that rely on platform-specific timing to take a little longer on startup when they run on Linux."
Kartik Patel
Ranch Hand

Joined: Sep 12, 2005
Posts: 73
Thanks Chris the link was really helpful.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Multithreading in monoprocess OS
 
Similar Threads
logger a static var or not
Compiler inconsistencies?
use of ArrayList in Java classes, EJB classes
ArrayList & Vector
What is worker thread and green thread.