Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:
JavaWorld Daily Brew

related to servlet


Back to:
www.javaworld.com/javaworld/jw-04-1996/jw-04-threads.html
.

i m harpreet here...i m employee of software company. i m trying to import own class in servlet class.i m unable to use own class in servlet class........plz help

Your rating: None Average: 2.8 (6 votes)

Please post relevant

Please post relevant compiler or runtime errors.

related to servlet

Can you please elaborate a little.
Are you recieving any err or NPE ?

related to servlet

If you are unable to import your own class then let someone else write that class for you then you can import(because u have problem with your OWN class and now class is written by someone else).

If someone else writes that

If someone else writes that class. Then it becomes private to him.

Now you can use that class in your servlet.

You are not able to use your class because your class does not like to sit in your own servlet.

voov im becoming intelligent....

try this

write class in a separate file
use absloute address technique
try to import that class into your current class file

plaese solve

for(int i=1;i<=5;i++)
{
System.out.println("\t from thread A:i="+i);
}
System.out.println("exit from A");
}
}
class B implements Runnable
{
public void run()
{
for(int j=1;j<=5;j++)
{
System.out.println("\t from thread B:j="+j);
}
System.out.println("exit from B");
}
}
class C implements Runnable
{
public void run()
{
for(int k=1;k<=5;k++)
{
System.out.println("\t from thread C:k="+k);
}
System.out.println("exit from C");
}
}
public class Threadcreation
{
public static void main(String args[])
{
A threadA=new A();
B threadB=new B();
C threadC=new C();
threadA.start();
threadB.start();
threadC.start();
}
}

GETTING AN ERROR:
CANNOT RESOLVE SYMBOL
threadA.START();

threadA is not a thread,

threadA is not a thread, it's an "A" object.

Try renaming threadA, threadB, and threadC to
objA, objB, objC

then,

Thread threadA = new Thread(objA);
Thread threadB = new Thread(objB);
Thread threadC = new Thread(objC);

Then you can do the .start() methods

I'm not sure why when running the sample code the higher priorit

I'm not sure why when running the sample code the higher priority thread seems slower to count, because I would have expected it to work the other way round, intuitively...

i want thred examle program

i want thred examle program

extends who and implements what

i got confused with terms extending and implementing classes and interfaces..(>_<;)
i didn't understand a thing about using interfaces and their difference in extending a class..may god help me..

java thread

can ne one suggest good reference site/book for java thread.

nice

That's a nice tutorial for everybody who needs to refresh their knowledge in Java. Beginners should read and understand the concepts of object oriented language... that's sure!

Little nitpick

Did you guys actually capitalize an instance variable in that example? (int Count) I'm ashamed and appalled good sirs!

counting alive threads

Can you suggest a way for finding out the number of alive threads in a program..

using isAlive() method of thread you can find out the no of aliv

using isAlive() method of thread you can find out the no of alive threads in program...

Java threads reference

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <p> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br /> <br> <strike>
  • Lines and paragraphs break automatically.
  • Use <!--pagebreak--> to create page breaks.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
Just checking to see if you're an actual person rather than a spammer. Sorry for the inconvenience.