Java Runtime classJava Runtime class is used to interact with java runtime environment. Java Runtime class provides methods to execute a process, invoke GC, get total and free memory etc. There is only one instance of java.lang.Runtime class is available for one java application. The Runtime.getRuntime() method returns the singleton instance of Runtime class. Important methods of Java Runtime class
Java Runtime exec() methodHow to shutdown system in JavaYou can use shutdown -s command to shutdown system. For windows OS, you need to provide full path of shutdown command e.g. c:\\Windows\\System32\\shutdown. Here you can use -s switch to shutdown system, -r switch to restart system and -t switch to specify time delay. How to shutdown windows system in JavaHow to restart system in JavaJava Runtime availableProcessors()Java Runtime freeMemory() and totalMemory() methodIn the given program, after creating 10000 instance, free memory will be less than the previous free memory. But after gc() call, you will get more free memory. Total Memory: 100139008 Free Memory: 99474824 After creating 10000 instance, Free Memory: 99310552 After gc(), Free Memory: 100182832 Next TopicSynchronization in java |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India