Java Thread.enumerate(Thread [] tarray)

Syntax

Thread.enumerate(Thread [] tarray) has the following syntax.

public static int enumerate(Thread [] tarray)

Example

In the following code shows how to use Thread.enumerate(Thread [] tarray) method.


//from   ww w . j  av a 2 s. c o m
public class Main {

  public static void main(String[] args) {
    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");

    System.out.println("Thread = " + t);

    int count = Thread.activeCount();
    System.out.println("currently active threads = " + count);

    Thread th[] = new Thread[count];
    Thread.enumerate(th);

    for (int i = 0; i < count; i++) {
      System.out.println(i + ": " + th[i]);
    }
  }
}




















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable