Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Create and launch a new thread  RSS feed

 
HiBob Chu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method in the Thread class is used to create and launch a new thread of execution?
A. Run();
B. Start();
B. Execute();
C. Run(Runnable r);
D. Start(Runnable r);
E. Execute(Thread t);
Answer: B
I think D is right too.
 
zarina mohammad
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
start() method does not take any parameters.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can usually resolve your doubts by checking the documentation.
Also, Java is case-sensitive.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The correct answer is none of the above. The correct method is start().
 
HiBob Chu
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I remember wrong:
If want to creat and excute a
thread with another object which
don't extends thread class, should
pass the object into thread constructor
instead of it's start function.
Thansk above!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!