Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multithreading in monoprocess OS

 
Kartik Patel
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Chris Beckey
Ranch Hand
Posts: 116
Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Chris the link was really helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic