Fork processes.

Alexandre Oliva oliva at
Tue Feb 9 20:08:02 PST 1999

On Feb  8, 1999, wayne <infotechsys at> wrote:

> Alexandre Oliva wrote:
>> On Feb  8, 1999, wayne <infotechsys at> wrote:

>> > how to do a fork in a java program ? Can this be done?

>> Nope

> I want to make sure I understand you.  If I have a Invoice system.
> Customer system, Inventory control system , and they all interact
> with one another, then I would drive them thru one main() method.

If they're all written in Java, you could start them in separate
Threads instead of firing off new processes.  If they're separate
programs, you can use Runtime.exec() to start them.  But in Java you
can't just fork() an (almost) identical copy of a process as in
C/Unix, and doing it in native code is very dangerous too, because
the work of other threads will be duplicated in the parent and the
child process, which is certainly not what you mean.

For short: if you mean fork() followed by exec(), you want
Runtime.exec().  If you mean running multiple Java applications
concurrently, threads may do the job.  Otherwise, you can't fork()

Alexandre Oliva  aoliva@{}
Universidade Estadual de Campinas, SP, Brasil

More information about the kaffe mailing list