• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread start()

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
Thomas
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
-Barry
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.)
-Barry
[ October 15, 2002: Message edited by: Barry Gaunt ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic