CPU占用率太高,最高可达到95%
最近一个项目里有需求,需要持续不断的从条形码中读取数据,持续读取时间无上限,可能几天甚至几个星期,代码写好,但是发现长时间(有时几个小时有时几天)扫描CPU占用率出奇高,最高达95%,截取log未报任何异常, 然后系统就GG了,只能重启;
下面贴出简化後的Code , 哪位大侠遇到过或能提供思路,甚至解决方案,在下感激不尽!!!!
private void startReceive() {
stopReceive = false;
new Thread(new Runnable() {
@Override
public void run() {
int timeout = 1000;
while (!stopReceive) {
if (mUsbDeviceConnection != null) {
try {
byte[] receiveBytes = new byte[64];
int value = mUsbDeviceConnection.bulkTransfer(mUsbEndpoint, receiveBytes,
receiveBytes.length, timeout);
if (value > 0) {
for (int i = 2; !stopReceive && i < receiveBytes.length; i++) {
byte b = receiveBytes[i];
if (b != 0) {
result += new String(new byte[]{b});
}
if (!stopReceive && !result.equals("") && result != null) {
Runtime.getRuntime().exec("input text " + result);
}
}
}
Thread.sleep(100);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}).start();
}
下面贴出简化後的Code , 哪位大侠遇到过或能提供思路,甚至解决方案,在下感激不尽!!!!
private void startReceive() {
stopReceive = false;
new Thread(new Runnable() {
@Override
public void run() {
int timeout = 1000;
while (!stopReceive) {
if (mUsbDeviceConnection != null) {
try {
byte[] receiveBytes = new byte[64];
int value = mUsbDeviceConnection.bulkTransfer(mUsbEndpoint, receiveBytes,
receiveBytes.length, timeout);
if (value > 0) {
for (int i = 2; !stopReceive && i < receiveBytes.length; i++) {
byte b = receiveBytes[i];
if (b != 0) {
result += new String(new byte[]{b});
}
if (!stopReceive && !result.equals("") && result != null) {
Runtime.getRuntime().exec("input text " + result);
}
}
}
Thread.sleep(100);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}).start();
}
...全文
相关推荐
Prime95(CPU稳定性)
Prime95(CPU稳定性) 主测CPU和内存。
【YOLOv8/v9/v10 实战 05】YOLO26 深度解析:无NMS端到端架构+边缘原生优化,CPU推理提速43%的落地实战
2026年Ultralytics推出的YOLO26标志着目标检测从“云端优先”转向“边缘优先”的范式转移,其原生无NMS端到端设计、DFL移除、STAL小目标感知标签分配、MuSGD优化器四大核心创新,大幅降低了边缘部署难度。本文从工业落地视角出发,拆解YOLO26的架构原理与技术演进脉络,结合PCB缺陷检测虚拟实战,完整演示环境搭建、自定义数据集训练、OpenVINO INT8量化、纯CPU端部署全流程,附多硬件部署适配模板与高频踩坑解决方案。读者可快速掌握YOLO26从原理到边缘落地的全链路技术
CPU检测软件CPUZv1.95 x64
CPU检测软件CPUZv1.95,64位操作系统
易语言源码易语言取指定进程CPU占用率源码
易语言源码易语言取指定进程CPU占用率源码
FIX95CPU.ISO
虚拟机在安装Windows 95过程中如发生错误,请下载此文件导入到光盘,从DVD/CD启动,然后一直按Y,重启后从硬盘启动,就可以正常安装了。(PS:找了好久...)


