JVM Inernals :
Hi All,
In this post I would like to tell you how many jvm's are created for multiple java applications.
Take an Example that you have a class with the Name ReadText.java
this java file has below code in it,
public class ReadText {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("Enter any text:");
s.next();
}
}//end class
compile the above code " javac ReadText.java" -- > ReadText.class
now see
when you type jps, you will see number of jvm processes are running in the current OS.
Then open two terminals and run the above .class "java ReadText" from two Terminals , and don't enter any text, just wait and type jps again in the third terminal.
Now you will see number of java processes running currently in this OS.
693, 709 are two java PS are running and in each jvm same ReadText app is running, Observe ReadText apps are waiting for user input , It means those two jvms are waiting for user input,.
Once user enter's any text and press Enter Button, then the jvm PS will automatically closed.
For example , let us enter any text in the left terminal and press Enter button.
See above picture, process number 693 is executed and closed successfully. and another jvm at right terminal is still waiting for user input. so we have 709 PS.
If you enter any text in the right terminal, that PS also will be closed successfully.
Note:
1) Here don't think PS number 8491, because eclipse is running in the back ground, and that is also another JVM PS. And similarly PS numbers 31530, 4080 are JVM Processes which runs jps command, jps closes automatically once execution is completed.
2) According to Operating System also these JVM PSs are different processes and OS assigns separate process ID for each.
Please let me know if any mistakes are here in this post, give your feedback at nagarjuna.lingala@gmail.com or javaojavablog@googlegroups.com
Hi All,
In this post I would like to tell you how many jvm's are created for multiple java applications.
Take an Example that you have a class with the Name ReadText.java
this java file has below code in it,
public class ReadText {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("Enter any text:");
s.next();
}
}//end class
compile the above code " javac ReadText.java" -- > ReadText.class
now see
when you type jps, you will see number of jvm processes are running in the current OS.
Then open two terminals and run the above .class "java ReadText" from two Terminals , and don't enter any text, just wait and type jps again in the third terminal.
Now you will see number of java processes running currently in this OS.
693, 709 are two java PS are running and in each jvm same ReadText app is running, Observe ReadText apps are waiting for user input , It means those two jvms are waiting for user input,.
Once user enter's any text and press Enter Button, then the jvm PS will automatically closed.
For example , let us enter any text in the left terminal and press Enter button.
See above picture, process number 693 is executed and closed successfully. and another jvm at right terminal is still waiting for user input. so we have 709 PS.
If you enter any text in the right terminal, that PS also will be closed successfully.
Note:
1) Here don't think PS number 8491, because eclipse is running in the back ground, and that is also another JVM PS. And similarly PS numbers 31530, 4080 are JVM Processes which runs jps command, jps closes automatically once execution is completed.
2) According to Operating System also these JVM PSs are different processes and OS assigns separate process ID for each.
Please let me know if any mistakes are here in this post, give your feedback at nagarjuna.lingala@gmail.com or javaojavablog@googlegroups.com
No comments:
Post a Comment