B10:Java Program to List the processes for the current shell, Display information about processes, Display the global priority of a process, Change the priority of a process with default arguments.
program:
package hello;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class PropriJava
{
public static void main(String args[])
{
try
{
String line;
Process p=Runtime.getRuntime().exec("ps axl");
BufferedReader input=new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader input1=new BufferedReader(new InputStreamReader(System.in));
while((line=input.readLine())!=null)
{
System.out.println(line);
}
input.close();
System.out.println("Enter the pid which value u want to change");
int a=Integer.parseInt(input1.readLine());
System.out.println(a);
Process p1=Runtime.getRuntime().exec("renice 10 -p "+a);
Process p2=Runtime.getRuntime().exec("ps axl");
BufferedReader input2=new BufferedReader(new InputStreamReader(p2.getInputStream()));
while((line=input2.readLine())!=null)
{
System.out.println(line);
}
}
catch(Exception err)
{
err.printStackTrace();
}
}
}
0 comments:
Post a Comment