Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

thread

 
geetanjali rajput
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
geetanjali rajput
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i will post the code. still thanks for the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic