簡體   English   中英

如何限制Android CPU使用率?

[英]How to limit Android CPU usage?

我有一個弱電話,我想做一些占用大量CPU時間的計算。

如何監控應用程序的CPU使用情況,以便我可以動態設置線程優先級或執行程序最大線程數?

從來沒有實現過,但對你的問題非常感興趣並做了一些挖掘。

所以來自roman10

private String getInfo() {
StringBuffer sb = new StringBuffer();
sb.append("abi: ").append(Build.CPU_ABI).append("n");
if (new File("/proc/cpuinfo").exists()) {
    try {
        BufferedReader br = new BufferedReader(new FileReader(new File("/proc/cpuinfo")));
        String aLine;
        while ((aLine = br.readLine()) != null) {
            sb.append(aLine + "n");
        }
        if (br != null) {
            br.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } 
}
return sb.toString();
}

這篇文章也可以幫到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM