国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > Android > 正文

android獲取手機(jī)cpu并判斷是單核還是多核

2020-04-11 12:31:34
字體:
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

/**
* Gets the number of cores available in this device, across all processors.
* Requires: Ability to peruse the filesystem at "/sys/devices/system/cpu"
* @return The number of cores, or 1 if failed to get result
*/
private int getNumCores() {
//Private Class to display only CPU devices in the directory listing
class CpuFilter implements FileFilter {
@Override
public boolean accept(File pathname) {
//Check if filename is "cpu", followed by a single digit number
if(Pattern.matches("cpu[0-9]", pathname.getName())) {
return true;
}
return false;
}
}

try {
//Get directory containing CPU info
File dir = new File("/sys/devices/system/cpu/");
//Filter to only list the devices we care about
File[] files = dir.listFiles(new CpuFilter());
//Return the number of cores (virtual CPU devices)
return files.length;
} catch(Exception e) {
//Default to return 1 core
return 1;
}
}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 绥德县| 玉屏| 突泉县| 黄龙县| 鸡泽县| 仁化县| 普陀区| 岫岩| 栾川县| 历史| 同仁县| 尼勒克县| 霍林郭勒市| 科尔| 曲阜市| 平安县| 玉山县| SHOW| 岚皋县| 岱山县| 上虞市| 历史| 宜都市| 漾濞| 八宿县| 开原市| 贵定县| 塔城市| 松原市| 荆州市| 富阳市| 宝山区| 稷山县| 乌审旗| 桦甸市| 宣恩县| 临夏县| 阿合奇县| 漳州市| 蒙自县| 万全县|