This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
why a call to super here
ima clark
Greenhorn
Joined: Apr 23, 2002
Posts: 19
posted
Jul 10, 2002 14:42:00
0
public class ThreadTest { public static void main(String[]args){ PrintThread pt = new PrintThread ( "hello thread" ); pt.start(); } } class PrintThread extends Thread{ private int sleepTime; public PrintThread( String name ){ super( name ); sleepTime = (int) (Math.random() * 50); System.out.println(getName()); } public void run(){ try{ System.out.println(getName()); Thread.sleep( sleepTime ); } catch (InterruptedException e){ System.out.println(e.toString()); } } }
why is there a call to super(name)?
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
Jul 10, 2002 15:04:00
0
That will invoke the Thread constructor that takes a
string
parameter. That assigns a name to the Thread object.
Associate Instructor - Hofstra University
Amazon Top 750 reviewer
-
Blog - Unresolved References
-
Book Review Blog
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: why a call to super here
Similar Threads
doubt in join method.
Setting a value for Sleep from the command line
some problems regd threads as in velmurugan's notes
Question about Thread (using the wait() and notifyAll()/notify() methods in a synchronized block)
I Cannot Get My Thread Program Compiled
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter