国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 宜兰市| 滕州市| 林甸县| 呼图壁县| 会宁县| 佛山市| 镇赉县| 定结县| 贵南县| 沁源县| 泰安市| 通许县| 砀山县| 定州市| 邢台市| 永登县| 秭归县| 潜山县| 宁河县| 绵阳市| 西青区| 茌平县| 沾益县| 搜索| 镇平县| 平安县| 区。| 泾源县| 定日县| 云和县| 泰来县| 体育| 江陵县| 博乐市| 罗定市| 盘锦市| 新乡市| 高唐县| 新郑市| 广昌县| 广昌县|