wood burning stoves 2.0*
The moose likes Java in General and the fly likes Multiple instances of java class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Multiple instances of java class" Watch "Multiple instances of java class" New topic
Author

Multiple instances of java class

Neo Snyder
Greenhorn

Joined: Feb 14, 2003
Posts: 1
I have written a simple java program test.java
import java.io.*;
public class test{
public static void main(String args[]){
while(true){
System.out.println("hello");
}
}
}
when i run this program using the command
java test& , 10 instances of this program is shown in the process listing.Iam working in linux
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Noe!
On Windows XP Professional, the task manager shows only one JAVA.EXE process (using about 5MB of memory and very little CPU time).
[ April 01, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
java test&
Not sure what this does in Linux, but if that is a wildcard then perhaps you are invoking multiple programs.
The "correct" syntax is
>java test
which should only start one JVM using one process.


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

Joined: Dec 06, 2001
Posts: 3061
In *nix, the & after a command detatches the newly created process from the terminal. This allows you to continue typing other commands on the command line while the program continues to run in the background.
How do you see that 10 instances of it are running? If you use the "ps" or "top" commands it should only list a signle instance. However, I haven't tried it myself. You have definitely piqued my curiosity. I'll have to check this out when I have a chance at home this evening.
Layne


Java API Documentation
The Java Tutorial
Eddy Chang
Greenhorn

Joined: Apr 05, 2001
Posts: 27
On linux.

$java -version



$java test &
The other java processes listed are child threads spawned by the jvm.

$ps auxwwf | grep echang


What are the other threads? The ones listed in the thread dump.
$kill -QUIT 5257


[ April 07, 2003: Message edited by: Eddy Chang ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple instances of java class
 
Similar Threads
Question on Array
static in a method
Access Modifiers little bit confusion... Help with World..
Problems runing java prograns
JSTL: equality test against a static member