17、java.lang.Runtime類
一、Runtime類
各Javaアプリケーションは、実行されている環境に接続できるように、Runtimeクラスのインスタンスを有する。 は、getRuntime方式で現在の運転時を取得することができる。 アプリケーションは独自のRuntimeクラスのインスタンスを作成できません。 二、常用方法
三、Process類
ProcessessBuider.start()とRuntime.exec方法は、本機のプロセスを作成し、Processサブクラスの一例に戻ります。 の例を使用して、プロセスを制御し、関連情報を得ることができる。 Process類は、プロセスからの入力、実行からプロセスへの出力、プロセスの完了待ち、プロセスの終了状態のチェック、破壊(殺す)プロセスを実行する方法を提供します。
public class Runtime
{
private static Runtime currentRuntime = new Runtime();
// Java
public static Runtime getRuntime() {
return currentRuntime;
}
/** Don't let anyone else instantiate this class */
private Runtime() {}
// **********************************************
/**
* Java 。
*
* , , 。
*/
public int availableProcessors(){}
// 。
// Process ,
public Process exec(String command)
throws IOException{}
// , Java ,System.exit(intnum)
public void exit(int status){}
// Java 。 gc freeMemory
public long freeMemory(){}
// , System.gc()
public void gc(){}
// Java 。 , Long.MAX_VALUE
public long maxMemory(){}
// Java , ,
public long totalMemory(){}
}
三、Process類
public abstract class Process
{
// 。 Process
public abstract void destroy();
/** , , Process 。
* , 。
* , ,
*/
public abstract int waitFor()
throws InterruptedException;
// 。 Process
public abstract OutputStream getOutputStream();
// 。 Process
public abstract InputStream getInputStream();
// 。 Process 。
public abstract InputStream getErrorStream();
}