java.lang.Thread.destroy()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(305)

本文整理了Java中java.lang.Thread.destroy()方法的一些代码示例,展示了Thread.destroy()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Thread.destroy()方法的具体详情如下:
包路径:java.lang.Thread
类名称:Thread
方法名:destroy

Thread.destroy介绍

[英]Throws NoSuchMethodError.
[中]抛出NoSuchMethodError。

代码示例

代码示例来源:origin: org.jvnet.hudson.plugins/perforce

public void stop() {
  runForever = false;
  if(null == decay_thread)
    return;
  try {
    decay_thread.interrupt();
    decay_thread.join(100);
  } catch(InterruptedException ex) {
    decay_thread.destroy();
  } catch(SecurityException ex) {
    decay_thread.destroy();
  }
}

代码示例来源:origin: eguid/FFmpegCommandHandler4java

/**
 * 销毁输出线程
 * @param outHandler
 * @return
 */
public static boolean stop(Thread outHandler) {
  if (outHandler != null && outHandler.isAlive()) {
    outHandler.stop();
    outHandler.destroy();
    return true;
  }
  return false;
}

代码示例来源:origin: stackoverflow.com

Thread t = new Thread();
t.interrupt();
t.stop();
t.destroy();

代码示例来源:origin: org.cogchar/org.cogchar.bundle.bind.cogbot

synchronized void killLocalProcessNow() {
  try {
    if (!killCogbotLocalOnShutdown) {
      return;
    }
    // so we dont change something
    isCogbotLocalChanging = true;
    isCogbotAvailable = false;
    if (localProcess == null) {
      return;
    }
    localProcess.destroy();
    if (localProcessThread != null) {
      localProcessThread.destroy();
    }
  } catch (Exception ex) {
    ex.printStackTrace(stdoutput);
    isCogbotAvailable = false;
    theLogger.log(Level.SEVERE, null, ex);
  }
}

代码示例来源:origin: entando/entando-core

@Override
public void destroy() {
  this.stopCommand();
  super.destroy();
}

代码示例来源:origin: EvoSuite/evosuite

@Override
@EvoSuiteExclude
public void destroy() {
  super.destroy();
}

代码示例来源:origin: org.cogchar/org.cogchar.bundle.bind.cogbot

static void killThread(Thread t) {
  if (t == null) {
    return;
  }
  if (!t.isAlive()) {
    return;
  }
  try {
    t.stop();
  } catch (Throwable th) {
  }
  if (!t.isAlive()) {
    return;
  }
  try {
    t.interrupt();
  } catch (Throwable th) {
  }
  if (!t.isAlive()) {
    return;
  }
  try {
    t.destroy();
  } catch (Throwable th) {
  }
}

代码示例来源:origin: org.jclouds/jclouds-antcontrib

/**
* @throws TimeoutException
*/
@SuppressWarnings("deprecation")
private void waitFor(final ChannelExec channel) throws TimeoutException {
 // wait for it to finish
 Thread thread = new Thread() {
   public void run() {
    while (!channel.isClosed()) {
      try {
       sleep(RETRY_INTERVAL);
      } catch (InterruptedException e) {
       // ignored
      }
    }
   }
 };
 thread.start();
 try {
   thread.join(maxwait);
 } catch (InterruptedException e) {
   // ignored
 }
 if (thread.isAlive()) {
   thread.destroy();
   throw new TimeoutException("command still running");
 }
}

代码示例来源:origin: com.jtransc/jtransc-rt

synchronized public final void destroy() {
  isDestroyed = true;
  for (Thread thread : getThreadsCopy()) thread.destroy();
  for (ThreadGroup group : getChildrenCopy()) group.destroy();
}

代码示例来源:origin: org.w3c.jigsaw/jigsaw

protected Reply dumpThread (Request request) 
throws HTTPException
{
// enumerate all thread, and return a full thread listing:
int    tcount   = Thread.activeCount() ;
Thread tarray[] = new Thread[tcount] ;
Thread.enumerate (tarray) ;
// Find ZE thread
String tname   = request.getQueryString () ;
Thread queried = null ;
for (int i = 0 ; i < tcount ; i++) {
  if ( tarray[i].getName().equals (tname) ) {
  queried = tarray[i] ;
  break ;
  }
}
if ( queried == null ) {
  Reply reply = request.makeReply(HTTP.NOT_FOUND);
  reply.setContent ("Thread " + tname + " not found.") ;
  return reply ;
} 
// Default to killing the thread
queried.destroy() ;
return listThreads (request) ;
}

相关文章