日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > java >内容正文

java

Java中的Runtime类详解

發(fā)布時間:2024/4/15 java 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java中的Runtime类详解 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

Java中的Runtime類詳解

1.類注釋

/**Every Java application has a single instance of class Runtime that allows the application to interface withthe environment in which the application is running. The current runtime can be obtained from the getRuntime method.每個java應(yīng)用有單個類Runtime實(shí)例【讓我想起了單例】,這允許應(yīng)用去和應(yīng)用正在運(yùn)行的環(huán)境交互。目前的runtime對象能夠從getRuntime()方法中獲得。An application cannot create its own instance of this class. 應(yīng)用程序本身不能創(chuàng)建這個類(Runtime)的實(shí)例@author unascribed@see java.lang.Runtime#getRuntime()@since JDK1.0*/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12

2.類代碼

  • 擁有一個靜態(tài)初始化對象——餓漢模式(感謝評論區(qū)的各位指正)。
private static Runtime currentRuntime = new Runtime();
  • 1
  • getRuntime()方法
/**Returns the runtime object associated with the current Java application.Most of the methods of class Runtime are instance methods and must be invoked with respect to the current runtime object.返回與當(dāng)前Java應(yīng)用關(guān)聯(lián)的runtime對象。大多數(shù)Runtime類的方法是實(shí)例方法,所以必須被調(diào)用與具體的當(dāng)前運(yùn)行時對象。@return the Runtime object associated with the current Java application.*/public static Runtime getRuntime() {return currentRuntime;}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • availableProcessors()方法
/**Returns the number of processors available to the Java virtual machine.返回Java虛擬機(jī)可用的處理器數(shù)。This value may change during a particular invocation of the virtual machine. Applications that are sensitive to the number of available processors should therefore occasionally poll this property and adjusttheir resource usage appropriately. @return the maximum number of processors available to the virtual machine; never smaller than one@since 1.4*/public native int availableProcessors(); }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • exec(String command)方法
/**Executes the specified string command in a separate process.在一個單獨(dú)的進(jìn)程中執(zhí)行指定的命令。This is a convenience method. An invocation of the form exec(command)behaves in exactly the same way as the invocation #exec(String, String[], File) exec(command, null, null).這是一個方便的方法。以exec(command)形式調(diào)用與exec(String,Stringp[],file)的表現(xiàn)是相同的。@param command a specified system command.【參數(shù):一個指定的系統(tǒng)命令】@return A new Process object for managing the subprocess【返回值:一個新的用于管理子進(jìn)程的的Process對象】@throws SecurityExceptionIf a security manager exists and its{@link SecurityManager#checkExec checkExec}method doesn't allow creation of the subprocess@throws IOExceptionIf an I/O error occurs@throws NullPointerExceptionIf <code>command</code> is <code>null</code>@throws IllegalArgumentExceptionIf <code>command</code> is empty@see #exec(String[], String[], File)@see ProcessBuilder*/public Process exec(String command) throws IOException {return exec(command, null, null);}

總結(jié)

以上是生活随笔為你收集整理的Java中的Runtime类详解的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。