• 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

jcert thread question

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From JavaCertificate:
What is the name of the method used to execute a thread?
1. init()
2. start()
3. run()
4. resume()
5. go()
The given answer is 2 but that answer seems wrong to me. The start() method does not execute the thread, it moves the thread to ready state making the thread available for execution. The run() method seems like a better answer as it is actually executing the thread's logic.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way that's worded is a bit vague, but I think the point it's trying to get across is this:
If you have an object that implements Runnable, calling run() does not spawn a new thread. It's just another method call... You MUST call start() at some point, on a Thread object, in order to actually spawn a new thread.
so, if you have this:

If you understand that, you know most of what you need to know about
interface Runnable and how to start a thread, for the exam...
 
reply
    Bookmark Topic Watch Topic
  • New Topic