2 Mart 2020 Pazartesi

ProcessHandle Arayüzü

Giriş
Şu satırı dahil ederiz
import java.lang.ProcessHandle;
Açıklaması şöyle.
With Java 9, one can retrieve the PID of the process through a native call. This is achievable through the ProcessHandle  . Also, we can retrieve information about the currently running Java process and info (inner class of ProcessHandle) class/object that contains details on the process. We can also enlist or return a snapshot of all currently running processes in the system.
allProcesses metodu
Şöyle yaparız.
ProcessHandle.allProcesses().forEach(processHandle -> 
    System.out.println("PID: " + processHandle.pid() + 
    ", command: " + processHandle.info().command().orElse("Unknown")));
current metodu
Örnek
Şöyle yaparız
long pid = ProcessHandle.current().pid();
info metodu
java.lang.Info nesnesi döner

Örnek ver

Hiç yorum yok:

Yorum Gönder