• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

thread question from java cram  RSS feed

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have an application that executes the following line: Thread myT = new Thread(); Select all of the following statements that are correct. [Check all correct anwers]
A) The Thread myT is now in a runnable state.
B) The Thread myT has the priority of the Thread that executed the construction statement.
C) If myT.start() is called, the run method in the class where the construction statement appears will be executed.
D) If myT.stop() is called, the Thread can later be started with myT.start() and will execute the run method in the Thread class.

The ans is B. I am not very understand what it said in B and C! can anyone explain to me?
Thanks in advance and happy new year
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ans. B seems pretty clear. If you don't assign a priority to a thread it inherits the prority of the thread that created it, in this case the program thread ( I guess).
Ans. C is looking to see if you can distinguish between programs that use Runnable and those that use the Thread class to perform multi-threading. Since the thread constructor in this case doesn't take any arguments the new thread is using the run method of the thread class, if the new thread had been constructed with an object of the class in which it had been created and that class implented the Runnable interface, ques. B would have been a correct ans.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!