你可以这样
//Give you set of Threads
Set<Thread> setOfThread = Thread.getAllStackTraces().keySet();
//Iterate over set to find yours
for(Thread thread : setOfThread){
if(thread.getId()==yourThread.getId()){
thread.interrupt();
}
}
在Java中使用线程ID终止线程
你可以这样
//Give you set of Threads
Set<Thread> setOfThread = Thread.getAllStackTraces().keySet();
//Iterate over set to find yours
for(Thread thread : setOfThread){
if(thread.getId()==yourThread.getId()){
thread.interrupt();
}
}