Sorry, had to run an errand before I could finish my reply.
[JY]: Each JVM takes up one process. You can start other processes with other JVM instances;
[PP]: So can we install 2 JVMs on single hard disk? I'm confused. Please can you explain a little bit more. Maybe you're confusing JVM with JRE. A JRE is a set of files necessary to run Java; it's a subset of the JDK. Yes, you can install more than one JRE on your machine if you want, but this is only useful if they are different versions. There's no real need to have two copies of the same JRE. Now a JVM isn't a file or set of files - it's a program/process being run in memory on a machine, which used a JRE to get started, and continues to use a JRE whenever it needs to look something up (like dynamically loading a class definition from a library). You can have multiple JVMs using the same JRE, or different JREs. Every time you type "java MyClass" or whatever, you start a new JVM process which executes MyClass's main() method, until it exists. You can have many JVMs running simultaneously (if system memory allows it) - but in many cases, it will be more efficient to run multiple threads in a single JVM.
[JY]: If you need some sort of communication between two different processes, you can achieve this by writing to / reading from a socket. Or they can modify files. Or use RMI. [PP]: You mean considering other process as a remote Object? Ummm... the process itself isn't a remote object (I think), but objects in the other process can be remote objects seen through RMI. You can learn more about RMI from
Sun's RMI tutorial, or our
Distributed Java forum. I need to learn more about this myself (particularly since SCDJ may need it); apologies if my answer is in error here.
For a good discussion of how to use exec(), see
this article.
[PP]: I was going through Java2 Complete Reference and it says "Proces based multitasking is not under the control of Java, however multithreaded multitasking is"
What does this mean? and then how about your solution regarding spawning process with exec() call.
Can you please elaborate on it more. Well generally, a Java progam deals with only one process, the one that's running the JVM that your program is executing in. Most other processes have nothing to do with your JVM; if you want to interact with them in any way, you'd need to use the OS to do so. Using the exec() command is a spacial case (and an exception to the statment in the Complete Java Reference) - yes, you can interact with a process if you spawn it from Java using this technique. But the Process class is hard to use well; if you really want to work with a lot of different processes (as opposed to threads) you're probably better off working directly with the OS, e.g. through some shell script perhaps.
Hope that helps...
[ May 20, 2003: Message edited by: Jim Yingst ]