導入自 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 …