wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "thread" Watch "thread" New topic
Author

thread

geetanjali rajput
Greenhorn

Joined: Apr 02, 2002
Posts: 19
i have a class which implements runnable. in this class i have spawned a new thread with the name (t). after that when i create an instance of this class and use isAlive method ,i write it in the following way ( ob1.t.isAlive()). here ob1 is the instance of the class . please help me.
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by geetanjali rajput:
i have a class which implements runnable. in this class i have spawned a new thread with the name (t). after that when i create an instance of this class and use isAlive method ,i write it in the following way ( ob1.t.isAlive()). here ob1 is the instance of the class . please help me.

What???
If the name of the reference variable is ob1, you'll just want to use:

If you're having trouble with this, post the related part of your code, so we know what's happening.
Corey


SCJP Tipline, etc.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
geetanjali
The isAlive() method is an instance method of the Thread clas, meaning it needs an instance of a Thread object to call it.
Your syntax:
ob1.t.isAlive()
is not appropriate for that call, it looks like your trying to do something with nested classes. Are any of these inner classes?
Here is a small piece of code to show you how to use the isAlive method:

Also, you didn't really ask a question here. You told us what you were doing then said you needed help. Post some code and any error messages your getting if this doesn't help.
hope that helps
[ April 02, 2002: Message edited by: Dave Vick ]

Dave
geetanjali rajput
Greenhorn

Joined: Apr 02, 2002
Posts: 19
i will post the code. still thanks for the help.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: thread