packageshutdownr;importjava.util.*;publicclassMain{publicstaticvoidmain(String[]args){Datetime1_set=newDate();Datetime2_set=newDate();Datetime_now=newDate();time_now.getT…
package shutdownr;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Date time1_set=new Date();
Date time2_set=new Date();
Date time_now=new Date();
time_now.getTime();
time1_set.setHours(23);
time1_set.setMinutes(30);
time1_set.setSeconds(00);
time2_set.setHours(4);
time2_set.setMinutes(59);
time2_set.setSeconds(59);
while(true)
{
if(time1_set.compareTo(time_now)==-1&&time2_set.compareTo(time_now)==-1)
{
try
{
Runtime.getRuntime().exec(“shutdown -s -t 1”);
}
catch(Exception e)
{
System.out.println(“error”);
}
}
}
}
刚写的一个定时关机程序,但是资源占用很厉害,cpu占用率高达50%多,内存占用9900k左右。
哪位高人帮忙吧代码改进下,减少点资源的使用
}
展开