导入自 renren
据说是一道微软的面试题。如题,写程序,让Windows的任务管理器中的性能监视器呈现正弦曲线。


潜心钻研良久,得代码:(java)
public class sincpu {
private static final int cycle=1024,tick = 256;
public static void main (String[] args) throws InterruptedException {
for(int i = 0;;i++){
work(calcNextSleep(i % cycle));
sleep(tick - calcNextSleep(i % cycle));
}
}
private static long calcNextSleep(long i){
return (int …