This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Thread start() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Thread start()" Watch "Thread start()" New topic

Thread start()

Thomas Markl
Ranch Hand

Joined: Mar 08, 2001
Posts: 192
Which method you define as the starting point of new thread in a class
from which new the thread can be excution?

A.public void start()
B.public void run()
C.public void int()
D.public static void main(String args[])
E.public void runnable()
I think that start() describes the starting point of a new thread in a program and run() describes the activity the started thread does.
Is that true?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
I would interpret this question as expecting the public void run() to be chosen as the answer.
When the system gets around to running the thead it starts execution in the thread's run() method.
Calling start() justs tells the system that it can schedule the thread to be run at sometime in the future.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
in a class from which new the thread can be excution?
Reading the question carefully (or as I'd intepret it - concerning whether I'm careful you'll receive differing opinions), I think this quoted part would indicate that start() is the correct answer. The question would seem to be asking how to start a thread from some other class. If you just use run(), a new thread isn't created.
On a side note: Sometimes I don't really understand why the author of a question didn't just directly ask what they were getting at. I can understand trying to test one's understanding by asking questions in a different way, but sometimes they confuse the situation and obscure the actual purpose of the question too much while adding a possible second (or more) interpretation of the question based on its wording. OK, that's enough blah-blah nonsense from me...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Dirk, my interpretation of this is that method start has been called, and method run is where the started thread begins execution when the thread scheduler gets around to it. run is the method I would define.
It's 80% question interpretation and 20% finding the answer. (However, that 20% can be a pretty big chunk.)
[ October 15, 2002: Message edited by: Barry Gaunt ]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I won't stand strongly behind my opinion (guess) this time. You may well be correct. I suspect that a grammar correction may well help to aleviate some ambiguity.
At any rate, to begin to understand the threading model in Java, The Threads Lesson of Sun's Java Tutorial is a good place to start.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Thread start()
Similar Threads
doubt on thread
start() and run()
Whizlabs Thread Question
check my answer
Dan's thread question!!