

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the improvements in Process API in Java 9?
Java has improved Process API in Java 9 version that helps to manage and control operating system processes. In earlier versions, it's difficult to manage and control operating system processes by using Java. Now, new classes and interfaces have added in Java 9 to perform this task. The ProcessHandle interface identifies and provides control of native processes and also provides a method to check processes liveness and destroy the processes. The ProcessHandle.Info interface gives an Information snapshot of the process.
The Process API provides more information like:
- Process's native process ID
- Accumulated CPU time
- Parent process
- Method to destroy a process
- Process’s Descendants, etc
Example
public class ProcessTest { public static void main(String args[]) { ProcessHandle currentProcess = ProcessHandle.current(); System.out.println("PID: " + currentProcess.pid()); ProcessHandle.Info currentProcessInfo = currentProcess.info(); System.out.println("totalCpuDuration: " + currentProcessInfo.totalCpuDuration()); System.out.println("user: " + currentProcessInfo.user()); } }
Output
PID: 6004 totalCpuDuration: Optional[PT0.421875S] user: Optional[Tutorialspoint\User]
- Related Questions & Answers
- What are the CompletableFuture API improvements in Java 9?
- What are the core library changes in Process API in Java 9?
- What are the new methods added to Process API in Java 9?
- What are the improvements for @Deprecated annotation in Java 9?
- What are the improvements for try-with-resources in Java 9?
- How to get the parent process of the Process API in Java 9?
- How to terminate/destroy a process using Process API in Java 9?
- How to traverse a process tree of Process API in Java 9?
- What are the steps to execute Flow API in Java 9?
- How to get all children of a process using Process API in Java 9?
- What are the new features added to Stream API in Java 9?
- How to retrieve all processes data of Process API in Java 9?
- StackWalker API in Java 9?
- What is Platform Logging API in Java 9?
- How to get a snapshot of information about Process API in Java 9?
Advertisements