Threads

Hello

I'm creating a thread, eg MyThread thread = new MyThread("FreddyTheThready");.

After running it, I am interrupting it. I want to be able to print out the threads name eg, 'System.out.println( thread.getName + " was interrupted")', So "FreddyTheThready was interrupted", what call to super would I have to do this. If i just call the getName method, it returns numerical value and not the name I gave it.

Thanks.

[445 byte] By [Daniel_1982a] at [2007-10-3 4:00:43]
# 1
Solved my problem.I assigned it a name using the setName() method.Can someone please tell me if this is correct and that Im on the right track?Thanks, Daniel.
Daniel_1982a at 2007-7-14 21:59:48 > top of Java-index,Java Essentials,New To Java...
# 2
Are you calling super(name) in your constructor?
floundera at 2007-7-14 21:59:48 > top of Java-index,Java Essentials,New To Java...
# 3
No. Could I do it that way? Could you show me a sample? :)
Daniel_1982a at 2007-7-14 21:59:48 > top of Java-index,Java Essentials,New To Java...
# 4

?

I take it from your first reply that you have written your own class MyThread which extends Thread and it has a constructor that accepts a String as a parameter. Then all you need to do is place super(name), or whatever your parameter is called, as the first line of your constructor.

You should have covered the basics of calling super when you did inheritance. Go back and read your book and/or course material.

floundera at 2007-7-14 21:59:48 > top of Java-index,Java Essentials,New To Java...