Package java.lang.Thread

Examples of java.lang.Thread.State


   * @return an EnumMap with Thread states as the key and the number of threads in that state as the value
   */
  public EnumMap<Thread.State, AtomicInteger> getThreadStates() {
    EnumMap<Thread.State, AtomicInteger> map = new EnumMap<State, AtomicInteger>(Thread.State.class);
    for(ThreadInfo ti : threadMxBean.getThreadInfo(threadMxBean.getAllThreadIds())) {
      State st = ti.getThreadState();
      AtomicInteger ai = map.get(st);
      if(ai==null) {
        ai = new AtomicInteger(0);
        map.put(st, ai);
      }
View Full Code Here


    }

    // Finally, try to terminate the thread.
    tryToTerminate(t);

    State s = t.getState();
    String message =
        msg +
        (s != State.TERMINATED ? " (and NOT TERMINATED, left in state " + s  + ")": " (and terminated)") +
        ": " + t.toString() +
        " (stack trace is a snapshot location of the thread at the moment of killing, " +
View Full Code Here

    }

    // Finally, try to terminate the thread.
    tryToTerminate(t);

    State s = t.getState();
    String message =
        msg +
        (s != State.TERMINATED ? " (and NOT TERMINATED, left in state " + s  + ")": " (and terminated)") +
        ": " + t.toString() +
        " (stack trace is a snapshot location of the thread at the moment of killing, " +
View Full Code Here

    }

    // Finally, try to terminate the thread.
    tryToTerminate(t);

    State s = t.getState();
    String message =
        msg +
        (s != State.TERMINATED ? " (and NOT TERMINATED, left in state " + s  + ")": " (and terminated)") +
        ": " + t.toString() +
        " (stack trace is a snapshot location of the thread at the moment of killing, " +
View Full Code Here

    }

    // Finally, try to terminate the thread.
    tryToTerminate(t);

    State s = t.getState();
    String message =
        msg +
        (s != State.TERMINATED ? " (and NOT TERMINATED, left in state " + s  + ")": " (and terminated)") +
        ": " + t.toString() +
        " (stack trace is a snapshot location of the thread at the moment of killing, " +
View Full Code Here

    }

    // Finally, try to terminate the thread.
    tryToTerminate(t);

    State s = t.getState();
    String message =
        msg +
        (s != State.TERMINATED ? " (and NOT TERMINATED, left in state " + s  + ")": " (and terminated)") +
        ": " + t.toString() +
        " (stack trace is a snapshot location of the thread at the moment of killing, " +
View Full Code Here

  }
 
  public static void waitForThreadState(Thread thread, Thread.State targetState) {
    long start = System.currentTimeMillis();
    long check = start + 30;
    State currentState = thread.getState();
    while (currentState != targetState) {
      assertThat(currentState, is(not(Thread.State.TERMINATED)));
      long now = System.currentTimeMillis();
      if (now > check) {
        long elapsed = now - start;
View Full Code Here

    * internal thread will execute the <code>run</code> method of
    * this instance. Aside from starting the thread this will also
    * ensure the internal thread has a unique name.
    */
   public void start() {
      State state = thread.getState();
     
      if(state == NEW) {
         thread.start();
      }
   }
View Full Code Here

    }

    // Finally, try to terminate the thread.
    tryToTerminate(t);

    State s = t.getState();
    String message =
        msg +
        (s != State.TERMINATED ? " (and NOT TERMINATED, left in state " + s  + ")": " (and terminated)") +
        ": " + t.toString() +
        " (stack trace is a snapshot location of the thread at the moment of killing, " +
View Full Code Here

   */
  public static void append(StringBuilder b, ThreadInfo ti) {
    b.append('"').append(ti.getThreadName()).append('"');
    b.append(" ID=").append(ti.getThreadId());

    final State threadState = ti.getThreadState();
    b.append(" ").append(threadState);
    if (ti.getLockName() != null) {
      b.append(" on ").append(ti.getLockName());
    }
   
View Full Code Here

TOP

Related Classes of java.lang.Thread.State

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.