About 11,800 results
Open links in new tab
  1. In Java, how do you determine if a thread is running?

    Feb 4, 2014 · A thread is alive if it has been started and has not yet died. Sample Source Code's of classes java.lang.Thread and sun.misc.VM. package java.lang; public class Thread implements Runnable { public final native boolean isAlive(); // Java thread status value zero corresponds to state "NEW" - 'not yet started'.

  2. java - How to get the state of a thread? - Stack Overflow

    Nov 7, 2018 · If you want to be able to get the state, you have to keep a reference to the Thread; e.g. public class Countdown implements Runnable{ private final Thread t; public Countdown(){ t = new Thread(this); t.start(); } public Thread.State getState() { return t.getState(); } // ...

  3. Java JVM profiling, thread status - what does "Monitor" status mean?

    Mar 16, 2019 · These states are the same as mentioned in the Thread.State enum. "Wait" means, as the documentation says: A thread is in the waiting state due to calling one of the following methods: Object.wait with no timeout; Thread.join with no timeout; LockSupport.park

  4. java.lang.Thread - where does threadStatus come from?

    Nov 21, 2018 · This is an internal thread status that should reflect Thread State as NEW, RUNNABLE,.. I found a Netbeans issue that suggest that toThreadState() is/can be implemented outside JDK code: bugfix #262633, toThreadState() implemented locally, do not rely on JDK

  5. java - How to know if other threads have finished? - Stack Overflow

    Mar 24, 2018 · This class provides protected overridable beforeExecute(java.lang.Thread, java.lang.Runnable) and afterExecute(java.lang.Runnable, java.lang.Throwable) methods that are called before and after execution of each task. These can be used to manipulate the execution environment; for example, reinitializing ThreadLocals, gathering statistics, or ...

  6. java - How to monitor status of all threads created by executor …

    May 26, 2020 · You may extend ThreadPoolExecutor and use its methods beforeExecute(Thread t, Runnable r) and afterExecute(Runnable r, Throwable t) to monitor the status of the tasks/threads. You can find an example implementation in this article

  7. Understanding java.lang.Thread.State: WAITING (parking)

    Sep 30, 2011 · As per the java Thread State Documentation, A thread can go to WAITING state for three reasons: Object.wait with no timeout ; Thread.join with no timeout; LockSupport.park; When you call a park method on a Thread, it disables the thread for thread scheduling purposes unless the permit is available.

  8. What does java.lang.Thread.interrupt () do? - Stack Overflow

    Aug 28, 2010 · When a thread checks for an interrupt by invoking the static method Thread.interrupted, interrupt status is cleared. The non-static Thread.isInterrupted, which is used by one thread to query the interrupt status of another, does not change the interrupt status flag. Quote from Thread.interrupt() API: Interrupts this thread.

  9. java - Active threads in ExecutorService - Stack Overflow

    Nov 30, 2017 · The ExecutorService interface does not define a method to examine the number of worker threads in the pool, as this is an implementation detail

  10. multithreading - Java parked thread - Stack Overflow

    Apr 4, 2012 · See the Java Doc for Thread.state.WAITING. There are 3 ways to cause a thread to be in the WAITING status: Object.wait with no timeout; Thread.join with no timeout; LockSupport.park ; A thread in the waiting state is waiting for another thread to perform a particular action. For example, a thread that has called Object.wait() on an object is ...