获取不到自己创建的线程

自渡96 自渡96 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
android 创建了个线程并设置了线程名字,通过名字无法找到对应线程(大佬们能否帮忙看下)
获取线程

String threadName = "download";

for (Thread t : Thread.getAllStackTraces().keySet()) {
System.out.println("------------------------------"+t.getName());
if (t.getName().equals(threadName)) {
t.interrupt();//进不来这里
}
}

创建线程

Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
Download.download(strResult, handler);
} catch (Exception e) {
e.printStackTrace();
}
}
},threadName);
thread.start();
...全文
评论 2
收藏 已收藏
分享
返回顶部
自渡96
Android 80,490 成员 91,375 内容