您好,欢迎访问一九零五行业门户网

Java 9中进程API的核心库变化是什么?

in java 9, one can retrieve the pid of the process through a native call and can be achievable through the processhandle. we can also retrieve information about the currently running java process (jvm) and info (inner class of processhandle) class that contains details about the process. we can also return a snapshot of all currently running processes in the system.
exampleimport java.lang.processhandle.info;public class processapichanges { public void detailedapiinfo(processhandle processhandle) { info processinfo = processhandle.info(); system.out.println("detailed process info is provided below: "); system.out.println("[executable name] " + processinfo.command().get()); system.out.println("[user name] " + processinfo.user().get()); system.out.println("[start time] " + processinfo.startinstant().get().tostring()); } public static void main(string args[]) { system.out.println("process api changes (core library) "); processapichanges processapichanges = new processapichanges(); processhandle processhandle = processhandle.current(); system.out.println("[current process id] " + processhandle.pid()); processapichanges.detailedapiinfo(processhandle); processhandle.allprocesses() .filter(ph -> ph.info().command().ispresent()) .limit(4).foreach((process) -> processapichanges.detailedapiinfo(process)); }}
输出process api changes (core library)[current process id] 5724detailed process info is provided below:[executable name] c:\program files\java\jdk-9.0.4\bin\java.exe[user name] tutorialspoint\user[start time] 2020-04-01t07:35:43.152zdetailed process info is provided below:[executable name] c:\windows\system32\taskhostex.exe[user name] tutorialspoint\user[start time] 2020-04-01t04:14:36.241zdetailed process info is provided below:[executable name] c:\program files\synaptics\syntp\syntpenh.exe[user name] tutorialspoint\user[start time] 2020-04-01t04:14:36.257zdetailed process info is provided below:[executable name] c:\windows\explorer.exe[user name] tutorialspoint\user[start time] 2020-04-01t04:14:36.335zdetailed process info is provided below:[executable name] c:\program files (x86)\dell wireless\bluetooth suite\btvstack.exe[user name] tutorialspoint\user[start time] 2020-04-01t04:14:51.594z
以上就是java 9中进程api的核心库变化是什么?的详细内容。
其它类似信息

推荐信息