congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Thread.stop
Code IndexAdd Tabnine to your IDE (free)

How to use
stop
method
in
java.lang.Thread

Best Java code snippets using java.lang.Thread.stop (Showing top 20 results out of 1,494)

origin: nutzam/nutz

/**
 * 强行关闭所属线程
 * 
 * @param err
 *            传给Thread.stop方法的对象
 */
@SuppressWarnings("deprecation")
public void stop(Throwable err) {
  myThread.stop(err);
}
origin: javamelody/javamelody

@SuppressWarnings("deprecation")
private void stopThread(Thread thread) {
  // I know that it is unsafe and the user has been warned
  thread.stop();
}
origin: redisson/redisson

/**
 * Throws checked exceptions in un-checked manner.
 * Uses deprecated method.
 * @see #throwException(Throwable)
 */
@SuppressWarnings({"deprecation"})
public static void throwExceptionAlt(Throwable throwable) {
  if (throwable instanceof RuntimeException) {
    throw (RuntimeException) throwable;
  }
  Thread.currentThread().stop(throwable);
}
origin: fesh0r/fernflower

@SuppressWarnings("deprecation")
private static void killThread(Thread thread) {
 thread.stop();
}
origin: xalan/xalan

/**
 * Cleanup; called when applet is terminated and unloaded.
 */
public void destroy()
{
 if (null != m_trustedWorker)
 {
  m_trustedWorker.stop();
  // m_trustedWorker.destroy();
  m_trustedWorker = null;
 }
 m_styleURLOfCached = null;
 m_documentURLOfCached = null;
}
origin: xalan/xalan

/**
 * Automatically called when the HTML page containing the applet is no longer
 * on the screen. Stops execution of the applet thread.
 */
public void stop()
{
 if (null != m_trustedWorker)
 {
  m_trustedWorker.stop();
  // m_trustedWorker.destroy();
  m_trustedWorker = null;
 }
 m_styleURLOfCached = null;
 m_documentURLOfCached = null;
}   
 
origin: apache/ignite

  /** {@inheritDoc} */
  @Override public boolean stopThreadById(long id) {
    Thread[] threads = Thread.getAllStackTraces().keySet().stream()
      .filter(t -> t.getId() == id)
      .toArray(Thread[]::new);

    if (threads.length != 1)
      return false;

    threads[0].stop();

    return true;
  }
}
origin: stackoverflow.com

 Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);
for(Thread t:threadArray) {
  if(t.getName().contains("Abandoned connection cleanup thread")) {
    synchronized(t) {
      t.stop(); //don't complain, it works
    }
  }
}
origin: apache/ignite

/** {@inheritDoc} */
@Override public boolean stopThreadByUniqueName(String name) {
  Thread[] threads = Thread.getAllStackTraces().keySet().stream()
    .filter(t -> Objects.equals(t.getName(), name))
    .toArray(Thread[]::new);
  if (threads.length != 1)
    return false;
  threads[0].stop();
  return true;
}
origin: twosigma/beakerx

private void killThread(Thread thr) {
 if (null == thr) return;
 thr.interrupt();
 try {
  Thread.sleep(killThreadSleepInMillis);
 } catch (InterruptedException ex) {
 }
 if (!thr.getState().equals(State.TERMINATED)) {
  thr.stop();
 }
}
origin: robovm/robovm

/**
 * Requests the receiver Thread to stop and throw ThreadDeath. The Thread is
 * resumed if it was suspended and awakened if it was sleeping, so that it
 * can proceed to throw ThreadDeath.
 *
 * @deprecated Stopping a thread in this manner is unsafe and can
 * leave your application and the VM in an unpredictable state.
 */
@Deprecated
public final void stop() {
  stop(new ThreadDeath());
}
origin: robovm/robovm

/**
 * Stops every thread in this group and recursively in all its subgroups.
 *
 * @see Thread#stop()
 * @see Thread#stop(Throwable)
 * @see ThreadDeath
 *
 * @deprecated Requires deprecated method {@link Thread#stop()}.
 */
@SuppressWarnings("deprecation")
@Deprecated
public final void stop() {
  if (stopHelper()) {
    Thread.currentThread().stop();
  }
}
origin: robovm/robovm

@SuppressWarnings("deprecation")
private boolean stopHelper() {
  boolean stopCurrent = false;
  synchronized (threadRefs) {
    Thread current = Thread.currentThread();
    for (Thread thread : threads) {
      if (thread == current) {
        stopCurrent = true;
      } else {
        thread.stop();
      }
    }
  }
  synchronized (groups) {
    for (ThreadGroup group : groups) {
      stopCurrent |= group.stopHelper();
    }
  }
  return stopCurrent;
}
origin: apache/hive

public static void close(final int port){
 Thread thread = map.get(port);
 if(thread != null){
  thread.stop();
 }
}
origin: rapidoid/rapidoid

@SuppressWarnings("deprecation")
@Override
public T halt() {
  checkActive(true);
  thread.stop();
  try {
    thread.join();
  } catch (InterruptedException e) {
    // do nothing
  }
  return super.halt();
}
origin: cSploit/android

private void setStoppedState(String errorMessage) {
  mSendButton.setChecked(false);
  mRunning = false;
  try {
    if (mThread != null && mThread.isAlive()) {
      if (mSocket != null)
        mSocket.close();
      if (mUdpSocket != null)
        mUdpSocket.close();
      mThread.stop();
      mThread = null;
      mRunning = false;
    }
  } catch (Exception e) {
  }
  if (errorMessage != null && !isFinishing())
    new ErrorDialog(getString(R.string.error), errorMessage, this)
        .show();
}
origin: ben-manes/caffeine

/**
 * Finds missing try { ... } finally { joinPool(e); }
 */
void checkForkJoinPoolThreadLeaks() throws InterruptedException {
  Thread[] survivors = new Thread[5];
  int count = Thread.enumerate(survivors);
  for (int i = 0; i < count; i++) {
    Thread thread = survivors[i];
    String name = thread.getName();
    if (name.startsWith("ForkJoinPool-")) {
      // give thread some time to terminate
      thread.join(LONG_DELAY_MS);
      if (!thread.isAlive()) {
       continue;
      }
      thread.stop();
      throw new AssertionFailedError
        (String.format("Found leaked ForkJoinPool thread test=%s thread=%s%n",
                toString(), name));
    }
  }
}
origin: scouter-project/scouter

  ctx.thread.interrupt();
} else if ("stop".equalsIgnoreCase(action)) {
  ctx.thread.stop();
} else if ("resume".equalsIgnoreCase(action)) {
  ctx.thread.resume();
origin: scouter-project/scouter

  ctx.thread.interrupt();
} else if ("stop".equalsIgnoreCase(action)) {
  ctx.thread.stop();
} else if ("resume".equalsIgnoreCase(action)) {
  ctx.thread.resume();
origin: apache/ignite

/**
 * @throws Exception Thrown if test fails.
 */
@Test
public void testStopThreadByUniqueName() throws Exception {
  WorkersControlMXBean workersCtrlMXBean = new WorkersControlMXBeanImpl(null);
  Thread t = startTestThread();
  assertTrue(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME));
  t.join(500);
  assertFalse(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME));
  Thread t1 = startTestThread();
  Thread t2 = startTestThread();
  assertFalse(workersCtrlMXBean.stopThreadByUniqueName(TEST_THREAD_NAME));
  t1.stop();
  t2.stop();
}
java.langThreadstop

Javadoc

Forces the thread to stop executing.

If there is a security manager installed, its checkAccess method is called with this as its argument. This may result in a SecurityException being raised (in the current thread).

If this thread is different from the current thread (that is, the current thread is trying to stop a thread other than itself), the security manager's checkPermission method (with a RuntimePermission("stopThread") argument) is called in addition. Again, this may result in throwing a SecurityException (in the current thread).

The thread represented by this thread is forced to stop whatever it is doing abnormally and to throw a newly created ThreadDeath object as an exception.

It is permitted to stop a thread that has not yet been started. If the thread is eventually started, it immediately terminates.

An application should not normally try to catch ThreadDeath unless it must do some extraordinary cleanup operation (note that the throwing of ThreadDeath causes finally clauses of try statements to be executed before the thread officially dies). If a catch clause catches a ThreadDeath object, it is important to rethrow the object so that the thread actually dies.

The top-level error handler that reacts to otherwise uncaught exceptions does not print out a message or otherwise notify the application if the uncaught exception is an instance of ThreadDeath.

Popular methods of Thread

  • currentThread
  • sleep
    Causes the currently executing thread to sleep (temporarily cease execution) for the specified numbe
  • <init>
    Constructs a new Thread with no Runnable object, the given name and belonging to the ThreadGroup pas
  • start
    Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread
  • getContextClassLoader
    Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator
  • interrupt
    Interrupts this thread. Unless the current thread is interrupting itself, which is always permitted,
  • setDaemon
    Marks this thread as either a #isDaemon thread or a user thread. The Java Virtual Machine exits when
  • getName
    Returns this thread's name.
  • join
    Waits at most millis milliseconds plus nanos nanoseconds for this thread to die. This implementatio
  • setContextClassLoader
    Sets the context ClassLoader for this Thread. The context ClassLoader can be set when a thread is cr
  • setName
    Changes the name of this thread to be equal to the argumentname. First the checkAccess method of thi
  • interrupted
    Tests whether the current thread has been interrupted. Theinterrupted status of the thread is cleare
  • setName,
  • interrupted,
  • getStackTrace,
  • getId,
  • isInterrupted,
  • isAlive,
  • setPriority,
  • yield,
  • getThreadGroup,
  • getPriority

Popular in Java

  • Reactive rest calls using spring rest template
  • getSupportFragmentManager (FragmentActivity)
  • scheduleAtFixedRate (Timer)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now