i'm curious about Thread objects too, particularly how to read its
details/properties.
the docs says 'getStackTrace' returns an array obj called
StackTraceElement, but i've been unable to loop through it.
it'd be helpful is someone could post an example of how to use some of
the Thread methods.



On Jul 6, 4:45 am, Mihai DINCA <[email protected]> wrote:
> Hi Ching
>
> I don't think I understand the question. A Thread object is like any
> other Java object:
>
> -- You can instantiate it
> -- You can directly access its public fields and call its public methods
> -- You can directly (without instantiate an object) access the class
> static public fields and call the class static public methods.
>
> Hope it helps
> Mihai
>
> Kim Ching Koh a �crit :
>
> > Hi,
>
> > What is the difference between the "usual" java objects vs Thread
> > objects?  Are Thread objects actually sharing object/instance
> > variables, as compare to usual object where each object holds their
> > object variable.  I did some experiement, it seem I can't access into
> > thread object variables, hence it seems thread objects share
> > object/instance variables?  For example, i can invoke setInt() method
> > of this thread object:
>
> >     private static class MessageLoop implements Runnable {
> >         int id = 0;
> >         public void setInt(int id){
> >             this.id <http://this.id> = id;
> >         }
> >         public void run() {
> >             String importantInfo[] = {
> >                 "Mares eat oats",
> >                 "Does eat oats",
> >                 "Little lambs eat ivy",
> >                 "A kid will eat ivy too"
> >             };
> >             try {
> >                 for (int i = 0; i < importantInfo.length; i++) {
> >                     //Pause for 4 seconds
> >                     Thread.sleep(4000);
> >                     //Print a message
> >                     threadMessage(importantInfo[i]);
> >                 }
> >             } catch (InterruptedException e) {
> >                 threadMessage("I wasn't done!");
> >             }
> >         }
> >     }
>
> > Regards
> > KC
> > --
> > To post to this group, send email to
> > [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>
>

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to