List of usage examples for java.lang ThreadGroup ThreadGroup
public ThreadGroup(String name)
From source file:Main.java
public static ThreadGroup getThreadGroup() { if (logThreadGroup == null) { logThreadGroup = new ThreadGroup("LogThreadGroup"); }/* w w w . ja v a2 s .co m*/ return logThreadGroup; }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start();/* w ww . java 2s .c o m*/ Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); System.out.println("ParentThreadGroup for " + pGroup.getName() + " is " + pGroup.getParent().getName()); System.out.println("ParentThreadGroup for " + cGroup.getName() + " is " + cGroup.getParent().getName()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); pGroup.setDaemon(true);/*from ww w . j a v a 2 s.c om*/ ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); cGroup.setDaemon(true); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start(); Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); System.out.println("Is " + pGroup.getName() + " a daemon ThreadGroup? " + pGroup.isDaemon()); System.out.println("Is " + cGroup.getName() + " a daemon ThreadGroup? " + cGroup.isDaemon()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); pGroup.setMaxPriority(Thread.MAX_PRIORITY - 2); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); cGroup.setMaxPriority(Thread.NORM_PRIORITY); Thread t1 = new Thread(pGroup, this); t1.setPriority(Thread.MAX_PRIORITY); System.out.println("Starting " + t1.getName()); t1.start();// w ww . j a v a 2s .c o m Thread t2 = new Thread(cGroup, this); t1.setPriority(Thread.MAX_PRIORITY); System.out.println("Starting " + t2.getName()); t2.start(); System.out.println("Active threads in \"" + pGroup.getName() + "\" = " + pGroup.activeCount()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start();/*w w w .java 2s . co m*/ Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start();//from w w w.ja v a 2 s . c o m Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); System.out.println("Active group(child) threads in \"" + pGroup.getName() + "\" = " + pGroup.activeCount()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); int i = pGroup.getMaxPriority(); System.out.println("Maximum priority of ParentThreadGroup =" + i); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start();// w w w. j a va 2 s. c o m Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start();//w ww . j a v a 2 s. c o m Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); ThreadGroup[] grpList = new ThreadGroup[pGroup.activeGroupCount()]; int count = pGroup.enumerate(grpList); for (int i = 0; i < count; i++) { System.out.println("ThreadGroup " + grpList[i].getName() + " found"); } }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start();/*from w w w . j a v a 2 s .c o m*/ Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); System.out.println("Active threads in \"" + pGroup.getName() + "\" = " + pGroup.activeCount()); }
From source file:Main.java
public ThreadGroupDemo() { ThreadGroup pGroup = new ThreadGroup("Parent ThreadGroup"); ThreadGroup cGroup = new ThreadGroup(pGroup, "Child ThreadGroup"); Thread t1 = new Thread(pGroup, this); System.out.println("Starting " + t1.getName()); t1.start();/* w ww. j av a 2 s .c o m*/ Thread t2 = new Thread(cGroup, this); System.out.println("Starting " + t2.getName()); t2.start(); System.out.println("Active threads in " + pGroup.getName() + " = " + pGroup.activeCount()); System.out.println("Is " + pGroup.getName() + " a daemon ThreadGroup? " + pGroup.isDaemon()); System.out.println("Is " + cGroup.getName() + " a daemon ThreadGroup? " + cGroup.isDaemon()); }