Commit 847698a3 by 龙明普

[null-null]调整执行线程

parent 2fdf5cbc
...@@ -57,17 +57,19 @@ public class SendMqttServerImpl implements SendMqttServer { ...@@ -57,17 +57,19 @@ public class SendMqttServerImpl implements SendMqttServer {
XBMqttDataUtil xbMqttDataUtil = new XBMqttDataUtil(configParams); XBMqttDataUtil xbMqttDataUtil = new XBMqttDataUtil(configParams);
// TODO 动臂斗杆底漆喷涂机器人1 // 线程循环发送Mqtt
String threadName = "test-Thread";
killThreadByName(threadName);
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
while (true) { while (true) {
try { try {
dtoList.forEach(t->{ dtoList.forEach(t -> {
Long start = System.currentTimeMillis(); Long start = System.currentTimeMillis();
mqttStartClient.jqr(t, xbMqttDataUtil); mqttStartClient.jqr(t, xbMqttDataUtil);
Long end = System.currentTimeMillis(); Long end = System.currentTimeMillis();
System.out.println("-----------耗时:------------"+(end-start)/1000); System.out.println("-----------耗时:------------" + (end - start) / 1000);
}); });
Thread.sleep(sleepTime); Thread.sleep(sleepTime);
} catch (InterruptedException e) { } catch (InterruptedException e) {
...@@ -75,9 +77,30 @@ public class SendMqttServerImpl implements SendMqttServer { ...@@ -75,9 +77,30 @@ public class SendMqttServerImpl implements SendMqttServer {
} }
} }
} }
}, "test-Thread").start(); }, threadName).start();
} }
//根据线程名称中断线程
public boolean killThreadByName(String name) {
// 获取所有线程
ThreadGroup currentGroup = Thread.currentThread().getThreadGroup();
int noThreads = currentGroup.activeCount();
Thread[] lstThreads = new Thread[noThreads];
currentGroup.enumerate(lstThreads);
System.out.println("现有线程个数:" + noThreads);
for (int i = 0; i < noThreads; i++) {
String threadName = lstThreads[i].getName();
System.out.println("第" + i + "个线程名为:" + threadName);
// 中断指定的线程
if (threadName.equals(name)) {
System.out.println("中断线程:" + name);
lstThreads[i].interrupt();
return true;
}
}
return false;
}
public Map<String, String> jgqgj(String name) { public Map<String, String> jgqgj(String name) {
List<BldzCclmVo> jgqgjVos = scadaMapper.find(name); List<BldzCclmVo> jgqgjVos = scadaMapper.find(name);
......
...@@ -10,20 +10,6 @@ ...@@ -10,20 +10,6 @@
"reported": { "reported": {
"singleField": [ "singleField": [
{ {
"feilds": [ //报警类别的json格式
{
"AlarmMsg": [ //报警信息
{
"subTable": "buchongbianliang02", //集合名字
"dbField": "d63", //字段
"fieldDataType": "string", //类型
"iotField": "AlarmMsg" //IOT key名字
}
]
}
]
},
{
"subTable": "buchongbianliang02", "subTable": "buchongbianliang02",
"dbField": "d62", "dbField": "d62",
"fieldDataType": "FLOAT", "fieldDataType": "FLOAT",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论