home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- import java.io.PrintStream;
- import sun.misc.VM;
-
- public class ThreadGroup {
- ThreadGroup parent;
- String name;
- int maxPriority;
- boolean destroyed;
- boolean daemon;
- boolean vmAllowSuspension;
- int nthreads;
- Thread[] threads;
- int ngroups;
- ThreadGroup[] groups;
-
- private ThreadGroup() {
- this.name = "system";
- this.maxPriority = 10;
- }
-
- public ThreadGroup(String var1) {
- this(Thread.currentThread().getThreadGroup(), var1);
- }
-
- public ThreadGroup(ThreadGroup var1, String var2) {
- if (var1 == null) {
- throw new NullPointerException();
- } else {
- var1.checkAccess();
- this.name = var2;
- this.maxPriority = var1.maxPriority;
- this.daemon = var1.daemon;
- this.vmAllowSuspension = var1.vmAllowSuspension;
- this.parent = var1;
- var1.add(this);
- }
- }
-
- public final String getName() {
- return this.name;
- }
-
- public final ThreadGroup getParent() {
- this.checkAccess();
- return this.parent;
- }
-
- public final int getMaxPriority() {
- return this.maxPriority;
- }
-
- public final boolean isDaemon() {
- return this.daemon;
- }
-
- public synchronized boolean isDestroyed() {
- return this.destroyed;
- }
-
- public final void setDaemon(boolean var1) {
- this.checkAccess();
- this.daemon = var1;
- }
-
- public final void setMaxPriority(int var1) {
- synchronized(this){}
-
- int var2;
- ThreadGroup[] var3;
- try {
- this.checkAccess();
- if (var1 < 1) {
- this.maxPriority = 1;
- } else if (var1 < this.maxPriority) {
- this.maxPriority = var1;
- }
-
- var2 = this.ngroups;
- if (this.groups != null) {
- var3 = new ThreadGroup[var2];
- System.arraycopy(this.groups, 0, var3, 0, var2);
- } else {
- var3 = null;
- }
- } catch (Throwable var6) {
- throw var6;
- }
-
- for(int var4 = 0; var4 < var2; ++var4) {
- var3[var4].setMaxPriority(var1);
- }
-
- }
-
- public final boolean parentOf(ThreadGroup var1) {
- while(var1 != null) {
- if (var1 == this) {
- return true;
- }
-
- var1 = var1.parent;
- }
-
- return false;
- }
-
- public final void checkAccess() {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkAccess(this);
- }
-
- }
-
- public int activeCount() {
- synchronized(this){}
-
- int var1;
- int var2;
- ThreadGroup[] var3;
- try {
- if (this.destroyed) {
- byte var9 = 0;
- return var9;
- }
-
- var1 = this.nthreads;
- var2 = this.ngroups;
- if (this.groups != null) {
- var3 = new ThreadGroup[var2];
- System.arraycopy(this.groups, 0, var3, 0, var2);
- } else {
- var3 = null;
- }
- } catch (Throwable var8) {
- throw var8;
- }
-
- for(int var4 = 0; var4 < var2; ++var4) {
- var1 += var3[var4].activeCount();
- }
-
- return var1;
- }
-
- public int enumerate(Thread[] var1) {
- return this.enumerate((Thread[])var1, 0, true);
- }
-
- public int enumerate(Thread[] var1, boolean var2) {
- return this.enumerate((Thread[])var1, 0, var2);
- }
-
- private int enumerate(Thread[] var1, int var2, boolean var3) {
- int var4 = 0;
- ThreadGroup[] var5 = null;
- synchronized(this){}
-
- try {
- if (this.destroyed) {
- byte var12 = 0;
- return var12;
- }
-
- int var9 = this.nthreads;
- if (var9 > var1.length - var2) {
- var9 = var1.length - var2;
- }
-
- if (var9 > 0) {
- System.arraycopy(this.threads, 0, var1, var2, var9);
- var2 += var9;
- }
-
- if (var3) {
- var4 = this.ngroups;
- if (this.groups != null) {
- var5 = new ThreadGroup[var4];
- System.arraycopy(this.groups, 0, var5, 0, var4);
- } else {
- var5 = null;
- }
- }
- } catch (Throwable var11) {
- throw var11;
- }
-
- if (var3) {
- for(int var6 = 0; var6 < var4; ++var6) {
- var2 = var5[var6].enumerate(var1, var2, true);
- }
- }
-
- return var2;
- }
-
- public int activeGroupCount() {
- synchronized(this){}
-
- int var1;
- ThreadGroup[] var2;
- try {
- if (this.destroyed) {
- byte var8 = 0;
- return var8;
- }
-
- var1 = this.ngroups;
- if (this.groups != null) {
- var2 = new ThreadGroup[var1];
- System.arraycopy(this.groups, 0, var2, 0, var1);
- } else {
- var2 = null;
- }
- } catch (Throwable var7) {
- throw var7;
- }
-
- int var3 = var1;
-
- for(int var4 = 0; var4 < var1; ++var4) {
- var3 += var2[var4].activeGroupCount();
- }
-
- return var3;
- }
-
- public int enumerate(ThreadGroup[] var1) {
- return this.enumerate((ThreadGroup[])var1, 0, true);
- }
-
- public int enumerate(ThreadGroup[] var1, boolean var2) {
- return this.enumerate((ThreadGroup[])var1, 0, var2);
- }
-
- private int enumerate(ThreadGroup[] var1, int var2, boolean var3) {
- int var4 = 0;
- ThreadGroup[] var5 = null;
- synchronized(this){}
-
- try {
- if (this.destroyed) {
- byte var12 = 0;
- return var12;
- }
-
- int var9 = this.ngroups;
- if (var9 > var1.length - var2) {
- var9 = var1.length - var2;
- }
-
- if (var9 > 0) {
- System.arraycopy(this.groups, 0, var1, var2, var9);
- var2 += var9;
- }
-
- if (var3) {
- var4 = this.ngroups;
- if (this.groups != null) {
- var5 = new ThreadGroup[var4];
- System.arraycopy(this.groups, 0, var5, 0, var4);
- } else {
- var5 = null;
- }
- }
- } catch (Throwable var11) {
- throw var11;
- }
-
- if (var3) {
- for(int var6 = 0; var6 < var4; ++var6) {
- var2 = var5[var6].enumerate(var1, var2, true);
- }
- }
-
- return var2;
- }
-
- public final void stop() {
- synchronized(this){}
-
- int var1;
- ThreadGroup[] var2;
- try {
- this.checkAccess();
-
- for(int var5 = 0; var5 < this.nthreads; ++var5) {
- this.threads[var5].stop();
- }
-
- var1 = this.ngroups;
- if (this.groups != null) {
- var2 = new ThreadGroup[var1];
- System.arraycopy(this.groups, 0, var2, 0, var1);
- } else {
- var2 = null;
- }
- } catch (Throwable var7) {
- throw var7;
- }
-
- for(int var3 = 0; var3 < var1; ++var3) {
- var2[var3].stop();
- }
-
- }
-
- public final void suspend() {
- synchronized(this){}
-
- int var1;
- ThreadGroup[] var2;
- try {
- this.checkAccess();
-
- for(int var5 = 0; var5 < this.nthreads; ++var5) {
- this.threads[var5].suspend();
- }
-
- var1 = this.ngroups;
- if (this.groups != null) {
- var2 = new ThreadGroup[var1];
- System.arraycopy(this.groups, 0, var2, 0, var1);
- } else {
- var2 = null;
- }
- } catch (Throwable var7) {
- throw var7;
- }
-
- for(int var3 = 0; var3 < var1; ++var3) {
- var2[var3].suspend();
- }
-
- }
-
- public final void resume() {
- synchronized(this){}
-
- int var1;
- ThreadGroup[] var2;
- try {
- this.checkAccess();
-
- for(int var5 = 0; var5 < this.nthreads; ++var5) {
- this.threads[var5].resume();
- }
-
- var1 = this.ngroups;
- if (this.groups != null) {
- var2 = new ThreadGroup[var1];
- System.arraycopy(this.groups, 0, var2, 0, var1);
- } else {
- var2 = null;
- }
- } catch (Throwable var7) {
- throw var7;
- }
-
- for(int var3 = 0; var3 < var1; ++var3) {
- var2[var3].resume();
- }
-
- }
-
- public final void destroy() {
- synchronized(this){}
-
- int var1;
- ThreadGroup[] var2;
- try {
- this.checkAccess();
- if (this.destroyed || this.nthreads > 0) {
- throw new IllegalThreadStateException();
- }
-
- var1 = this.ngroups;
- if (this.groups != null) {
- var2 = new ThreadGroup[var1];
- System.arraycopy(this.groups, 0, var2, 0, var1);
- } else {
- var2 = null;
- }
-
- if (this.parent != null) {
- this.destroyed = true;
- this.ngroups = 0;
- this.groups = null;
- this.nthreads = 0;
- this.threads = null;
- }
- } catch (Throwable var5) {
- throw var5;
- }
-
- for(int var3 = 0; var3 < var1; ++var3) {
- var2[var3].destroy();
- }
-
- if (this.parent != null) {
- this.parent.remove(this);
- }
-
- }
-
- private final void add(ThreadGroup var1) {
- synchronized(this){}
-
- try {
- if (this.destroyed) {
- throw new IllegalThreadStateException();
- }
-
- if (this.groups == null) {
- this.groups = new ThreadGroup[4];
- } else if (this.ngroups == this.groups.length) {
- ThreadGroup[] var4 = new ThreadGroup[this.ngroups * 2];
- System.arraycopy(this.groups, 0, var4, 0, this.ngroups);
- this.groups = var4;
- }
-
- this.groups[this.ngroups] = var1;
- ++this.ngroups;
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- private void remove(ThreadGroup var1) {
- synchronized(this){}
-
- try {
- if (!this.destroyed) {
- for(int var4 = 0; var4 < this.ngroups; ++var4) {
- if (this.groups[var4] == var1) {
- --this.ngroups;
- System.arraycopy(this.groups, var4 + 1, this.groups, var4, this.ngroups - var4);
- this.groups[this.ngroups] = null;
- break;
- }
- }
-
- if (this.nthreads == 0) {
- this.notifyAll();
- }
-
- if (this.daemon && this.nthreads == 0 && this.ngroups == 0) {
- this.destroy();
- }
-
- return;
- }
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- void add(Thread var1) {
- synchronized(this){}
-
- try {
- if (this.destroyed) {
- throw new IllegalThreadStateException();
- }
-
- if (this.threads == null) {
- this.threads = new Thread[4];
- } else if (this.nthreads == this.threads.length) {
- Thread[] var4 = new Thread[this.nthreads * 2];
- System.arraycopy(this.threads, 0, var4, 0, this.nthreads);
- this.threads = var4;
- }
-
- this.threads[this.nthreads] = var1;
- ++this.nthreads;
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- void remove(Thread var1) {
- synchronized(this){}
-
- try {
- if (!this.destroyed) {
- for(int var4 = 0; var4 < this.nthreads; ++var4) {
- if (this.threads[var4] == var1) {
- System.arraycopy(this.threads, var4 + 1, this.threads, var4, --this.nthreads - var4);
- this.threads[this.nthreads] = null;
- break;
- }
- }
-
- if (this.nthreads == 0) {
- this.notifyAll();
- }
-
- if (this.daemon && this.nthreads == 0 && this.ngroups == 0) {
- this.destroy();
- }
-
- return;
- }
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
-
- public void list() {
- this.list(System.out, 0);
- }
-
- void list(PrintStream var1, int var2) {
- synchronized(this){}
-
- int var3;
- ThreadGroup[] var4;
- try {
- for(int var7 = 0; var7 < var2; ++var7) {
- var1.print(" ");
- }
-
- var1.println(this);
- var2 += 4;
-
- for(int var8 = 0; var8 < this.nthreads; ++var8) {
- for(int var9 = 0; var9 < var2; ++var9) {
- var1.print(" ");
- }
-
- var1.println(this.threads[var8]);
- }
-
- var3 = this.ngroups;
- if (this.groups != null) {
- var4 = new ThreadGroup[var3];
- System.arraycopy(this.groups, 0, var4, 0, var3);
- } else {
- var4 = null;
- }
- } catch (Throwable var11) {
- throw var11;
- }
-
- for(int var5 = 0; var5 < var3; ++var5) {
- var4[var5].list(var1, var2);
- }
-
- }
-
- public void uncaughtException(Thread var1, Throwable var2) {
- if (this.parent != null) {
- this.parent.uncaughtException(var1, var2);
- } else {
- if (!(var2 instanceof ThreadDeath)) {
- var2.printStackTrace(System.err);
- }
-
- }
- }
-
- public boolean allowThreadSuspension(boolean var1) {
- this.vmAllowSuspension = var1;
- if (!var1) {
- VM.unsuspendSomeThreads();
- }
-
- return true;
- }
-
- public String toString() {
- return this.getClass().getName() + "[name=" + this.getName() + ",maxpri=" + this.maxPriority + "]";
- }
- }
-