/** * 销毁输出线程 * @param outHandler * @return */ public static boolean stop(Thread outHandler) { if (outHandler != null && outHandler.isAlive()) { outHandler.stop(); outHandler.destroy(); return true; } return false; }
Thread t = new Thread(); t.interrupt(); t.stop(); t.destroy();
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); } }
@Override public void destroy() { this.stopCommand(); super.destroy(); }
@Override @EvoSuiteExclude public void destroy() { super.destroy(); }
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) { } }
/** * @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"); } }
synchronized public final void destroy() { isDestroyed = true; for (Thread thread : getThreadsCopy()) thread.destroy(); for (ThreadGroup group : getChildrenCopy()) group.destroy(); }
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) ; }