Example usage for java.lang Thread activeCount

List of usage examples for java.lang Thread activeCount

Introduction

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

Prototype

public static int activeCount() 

Source Link

Document

Returns an estimate of the number of active threads in the current thread's java.lang.ThreadGroup thread group and its subgroups.

Usage

From source file:Main.java

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.dumpStack();//from  ww w  .ja  v a  2 s  .com
}

From source file:Main.java

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);//from  w  w w.  j a  v a2  s . co  m

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

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(1);//from  w  w w  . j  a va 2 s  .  c  o  m

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

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

From source file:Main.java

public static void main(String[] args) {

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

    t.setName("java2s.com thread");

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

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

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(Thread.MIN_PRIORITY);

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

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

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(Thread.MAX_PRIORITY);

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

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

From source file:Main.java

public static void main(String[] args) {

    Thread t = Thread.currentThread();
    t.setName("java2s.com thread");
    // set thread priority to 1
    t.setPriority(Thread.NORM_PRIORITY);

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

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

From source file:MainClass.java

public static void main(String args[]) {
    Thread t = Thread.currentThread();
    t.setName("My Thread");
    t.setPriority(1);//from ww w  . ja va 2 s . c o m
    System.out.println("current thread: " + t);
    int active = Thread.activeCount();
    System.out.println("currently active threads: " + active);
    Thread all[] = new Thread[active];
    Thread.enumerate(all);
    for (int i = 0; i < active; i++) {
        System.out.println(i + ": " + all[i]);
    }
    Thread.dumpStack();
}

From source file:com.devti.JavaXMPPBot.FakeDaemonContext.java

public static void main(String[] args) {
    JavaXMPPBot daemon = new JavaXMPPBot();
    try {/*from  ww  w . j  av  a 2s  .  com*/
        daemon.init(new FakeDaemonContext(args));
        daemon.start();
        while (Thread.activeCount() > 1) {
            Thread.sleep(1000);
        }
    } catch (Exception e) {
        e.printStackTrace();
        //System.err.println("Can't load a bot: " + e.getLocalizedMessage());
        System.exit(1);
    }
}

From source file:com.sm.test.TestFailure.java

public static void main(String[] args) throws Exception {

    final HessianSerializer serializer = new HessianSerializer();
    final String fakeUrl = "some.faulty:8888";

    final RemotePersistence rpcClient = new GZRemoteClientImpl(fakeUrl, serializer, "rpc");
    final RemotePersistence ntyClient = new NTRemoteClientImpl(fakeUrl, serializer, "rpc");

    final Invoker invoker = new Invoker("someClass", "someMethod", new Object[] {});
    final int invokeCount = 100;

    for (int i = 0; i < invokeCount; i++) {
        try {//from   w w w.j a v  a  2  s . com

            ntyClient.invoke(invoker);
        } catch (Exception e) {
            logger.info("NT exception");
            logger.info(Thread.activeCount());
        }
    }

    for (int i = 0; i < invokeCount; i++) {
        try {
            rpcClient.invoke(invoker);
        } catch (Exception e) {
            logger.info("GZ exception");
            logger.info(Thread.activeCount());
        }
    }
}