Tutorial Addendum On Java - Cilia Groups

strategygamesios android appcolt appcolt
 31 December 18:00   

    



    



    

ThreadGroup Class

    



    

ThreadGroup: A chic represents a accumulating of Cilia altar and

    

ThreadGroup objects.

    



    

Features of ThreadGroup class:

    



        

  • All altar of ThreadGroup chic are organized as a timberline structure.

        

    Each ThreadGroup item haveto accept a ancestor ThreadGroup item in the tree,

        

    except the basis object.

        



  •     

  • The basis item of the ThreadGroup timberline is provided and managed by

        

    the Java Basic Apparatus ( JVM ).

        



  •     



    



    

Key methods:

    



        

  • getParent(): Allotment the ancestor ThreadGroup object.

        



  •     

  • activeCount(): Allotment the amount of alive Cilia altar in this

        

    ThreadGroup item and its sub-tree.

        



  •     

  • activeGroupCount(): Allotment the amount of alive ThreadGroup altar in

        

    this ThreadGroup item and its sub-tree.

        



  •     

  • enumerate(Thread[] l): Copies alive Cilia altar in this ThreadGroup

        

    item and its sub-tree.

        



  •     

  • enumerate(ThreadGroup[] l): Copies alive ThreadGroup altar in this

        

    ThreadGroup item and its sub-tree.

        



  •     

  • interrupt(): Calls Thread.interrupt() adjustment on

        

    all Cilia altar in this ThreadGroup item and its sub-tree.

        



  •     



    



    

The ThreadGroup Timberline

    



    

As I mentioned in the antecedent section, there is individual timberline anatomy

    

managed by the JVM to adapt all altar of ThreadGroup chic and Thread

    

class. Actuality are the rules of how this timberline is maintained:

    



        

  • The basis bulge of the timberline is a ThreadGroup item called "system".

        



  •     

  • The "system" cilia accumulation contains a amount of accoutrement performing

        

    JVM arrangement tasks.

        



  •     

  • The "system" cilia accumulation contains just one ThreadGroup item called "main".

        



  •     

  • The "main" cilia accumulation contains one cilia called "main", which is the

        

    starting cilia for the appliance program.

        



  •     

  • The "main" cilia accumulation contains no additional ThreadGroup objects.

        



  •     

  • If a new ThreadGroup item is created after a ancestor ThreadGroup object

        

    specified, it will be added into the "main" cilia group.

        



  •     

  • If a new Cilia item is created after a ThreadGroup item specified,

        

    it will be added into the "main" cilia group.

        



  •     



    



    

Here is a simple program assuming how to use some of the methods in ThreadGroup

    

class to get advice out of the ThreatGroup tree:

    

 

    

/**

    

* ThreadGroupTree.java

    

* Absorb (c) 2003 by Dr. Yang

    

*/

    

class ThreadGroupTree {

    

accessible changeless abandoned main(String[] args) {

    

Cilia t = Thread.currentThread();

    

ThreadGroup g = t.getThreadGroup();

    

g = g.getParent();

    

printInfo(g,"");

    

g.list();

    

}

    

accessible changeless abandoned printInfo(ThreadGroup g, Cord p) {

    

System.out.println(p+"ThreadGroup name = "+g.getName());

    

System.out.println(p+" Has ancestor cilia accumulation = "

    

+(g.getParent()!=null));

    

int n = g.activeCount();

    

System.out.println(p+" # of alive accoutrement = "+n);

    

Thread[] l = new Thread[n];

    

n = g.enumerate(l, false);

    

for (int i=0; i<n; i++) {

    

System.out.println(p+" Cilia name = "+l[i].getName());

    

}

    

n = g.activeGroupCount();

    

System.out.println(p+" # of alive sub cilia groups = "+n);

    

ThreadGroup[] s = new ThreadGroup[n];

    

n = g.enumerate(s, false);

    

for (int i=0; i<n; i++) {

    

printInfo(s[i]," "+p);

    

}

    

}

    

}

    



    



    



    

 


Tags: active, system, class, groups, contains, parent, group, public, object

 threadgroup, thread, object, objects, system, group, active, println, class, contains, parent, enumerate, printinfo, returns, groups, getparent, named, , threadgroup object, thread group, object and, sub tree, system out, group contains, main thread, thread objects, threadgroup objects, returns the, threadgroup class, parent threadgroup, thread groups, thread group contains, main thread group, system thread group, public static void, threadgroup object named, sub tree enumerate, parent threadgroup object, active thread objects, active threadgroup objects, java thread groups,

Share Tutorial Addendum On Java - Cilia Groups:
Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  java