Last active
May 16, 2019 11:37
-
-
Save kunals201/56088edc307608ce9cf8da1360223412 to your computer and use it in GitHub Desktop.
Get all the current process and print out id of each
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.knoldus; | |
import java.util.stream.Stream; | |
public class CurrentAllProcess { | |
public static void main(String[] args) throws Exception { | |
final Stream<ProcessHandle> currentProcesses = ProcessHandle.allProcesses(); | |
currentProcesses.filter(ProcessHandle::isAlive).forEach(processHandle -> | |
System.out.println(processHandle.pid())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment