Example usage for java.lang Thread stop

List of usage examples for java.lang Thread stop

Introduction

In this page you can find the example usage for java.lang Thread stop.

Prototype

@Deprecated(since = "1.2")
public final void stop() 

Source Link

Document

Forces the thread to stop executing.

Usage

From source file:org.synchronoss.cloud.nio.multipart.example.utils.ContextFinalizer.java

@Override
public void onApplicationEvent(ContextClosedEvent event) {

    if (log.isInfoEnabled())
        log.info("onApplicationEvent: " + event);

    Enumeration<Driver> drivers = DriverManager.getDrivers();
    Driver driver = null;//from www .j  av a2s  .c  o  m
    while (drivers.hasMoreElements()) {
        try {
            driver = drivers.nextElement();
            DriverManager.deregisterDriver(driver);
            if (log.isWarnEnabled())
                log.warn(String.format("Driver %s unregistered", driver));
        } catch (SQLException e) {
            if (log.isWarnEnabled())
                log.warn(String.format("Error unregistering driver %s", driver), e);
        }
    }
    Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
    Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
    for (Thread thread : threadArray) {
        if (thread.getName().contains("Abandoned connection cleanup thread")) {
            synchronized (thread) {
                thread.stop(); //don't complain, it works
            }
        }
    }
    if (log.isInfoEnabled())
        log.info("Finished processing onApplicationEvent");
}

From source file:org.nuxeo.ecm.core.opencmis.impl.CmisFeatureSessionHttp.java

@SuppressWarnings("deprecation")
protected void killRemainingServerThreads() throws Exception {
    QueuedThreadPool tp = (QueuedThreadPool) server.getThreadPool();
    int n = tp.getThreads();
    if (n == 0) {
        return;//ww  w.  j  a v a2 s  .co m
    }
    log.error(n + " Jetty threads failed to stop, killing them");
    Object threadsLock = getFieldValue(tp, "_threadsLock");
    @SuppressWarnings("unchecked")
    Set<Thread> threadSet = (Set<Thread>) getFieldValue(tp, "_threads");
    List<Thread> threads;
    synchronized (threadsLock) {
        threads = new ArrayList<Thread>(threadSet);
    }
    for (Thread t : threads) {
        t.stop(); // try to stop thread brutally
    }
}

From source file:com.sixt.service.framework.kafka.messaging.KafkaIntegrationTest.java

private void brutallyKillConsumer(String victimName) {
    int nbThreads = Thread.activeCount();
    Thread[] threads = new Thread[nbThreads];
    Thread.enumerate(threads);/*ww w  .  ja v a2  s.  co  m*/

    for (Thread t : threads) {
        if (t.getName().equals(victimName)) {
            logger.error("BOOM: Killing consumer thread {}", victimName);
            t.stop(); // used by intention despite deprecation
        }
    }
}

From source file:controller.servlet.AllDataDelete.java

/**
 * Mtodo stopThreads, permite parar los hilos en ejecucin.
 *//*w w w .ja v  a 2s  .c om*/
private void stopThreads() {
    Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
    Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
    for (Thread thread : threadArray) {
        if (thread.getName().equals(ThreadName.TRACK_THREAD_NAME)
                || thread.getName().equals(ThreadName.AMENITIES_THREAD_NAME)) {
            thread.interrupt();
            thread.stop();
        }
    }
}

From source file:org.openhab.binding.plum.PlumActiveBinding.java

/**
 * Clean up all state.//from w  w  w .j  a va 2 s. c  o  m
 */
private void shutdown() {
    logger.debug("shutting down binding");
    for (Thread t : threads.values()) {
        t.stop();
        t.destroy();
    }

}

From source file:com.kurento.kmf.test.client.BrowserClient.java

@SuppressWarnings("deprecation")
public void close() {
    for (Thread t : callbackThreads) {
        t.stop();
    }//from w w w . j  a  va  2s.  com
    driver.quit();
    driver = null;

}

From source file:org.hyperic.hq.measurement.agent.server.MeasurementCommandsServer.java

private void interruptThread(Thread t) throws InterruptedException {
    if (t.isAlive()) {
        t.interrupt();/*  ww w  .  j  a v a  2  s.co  m*/
        t.join(THREAD_JOIN_WAIT);

        if (t.isAlive()) {
            this.log.warn(t.getName() + " did not die within the " + "timeout period.  Killing it");
            t.stop();
        }
    }
}

From source file:org.kurento.test.browser.WebPage.java

@After
@SuppressWarnings("deprecation")
public void teardownKurentoServices() throws Exception {
    for (Thread t : callbackThreads) {
        t.stop();
    }/*w  w  w  . j  a va2  s.  co  m*/
}

From source file:fr.lirmm.graphik.graal.bench.homomorphism.InfHomomorphismBench.java

private DefaultUnionOfConjunctiveQueries rewrite(ConjunctiveQuery q) {

    Rewriter r = new Rewriter(q, onto, rc);
    Thread thread = new Thread(r);
    thread.start();/*  w  ww . java2s. c  o m*/
    try {
        thread.join(3600000); // 60min
    } catch (InterruptedException e1) {

    }
    if (thread.isAlive()) {
        thread.stop();
        return null;
    } else {
        return r.getUCQ();
    }

}

From source file:com.datatorrent.lib.appdata.query.SimpleDoneQueryQueueManagerTest.java

@SuppressWarnings({ "deprecation", "CallToThreadStopSuspendOrResumeManager" })
private void testBlocking(SimpleDoneQueueManager<Query, Void> sdqqm) throws InterruptedException {
    Thread thread = new Thread(new BlockedThread<Query, Void, MutableBoolean>(sdqqm));
    //thread.setUncaughtExceptionHandler(new RethrowExceptionHandler(Thread.currentThread()));
    thread.start();//from www  .j  a v a2  s. c o  m
    Thread.sleep(100);

    Assert.assertEquals(Thread.State.WAITING, thread.getState());

    thread.stop();
}