Java Programming - Threads - Discussion

1. 

What is the name of the method used to start a thread execution?

[A]. init();
[B]. start();
[C]. run();
[D]. resume();

Answer: Option B

Explanation:

Option B is Correct. The start() method causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.

Option A is wrong. There is no init() method in the Thread class.

Option C is wrong. The run() method of a thread is like the main() method to an application. Starting the thread causes the object's run method to be called in that separately executing thread.

Option D is wrong. The resume() method is deprecated. It resumes a suspended thread.


Srinu said: (Feb 3, 2011)  
Good explanation.

Rajarajan said: (Aug 17, 2011)  
Explain with any simple program.

Shakthi said: (Mar 22, 2013)  
Hi,

But start() methods only schedules the thread for execution and not actually begins the execution of the thread. The execution of the thread is started when the JVM calls the run() method of the thread once the CPU Scheduler picks this scheduled thread for execution.

Any one can please explain for this.

Ananya said: (Jun 2, 2013)  
Hi,

Yes, the answer is correct. I want to clear to shakthi. That when we are calling start() , thread goes to 'ready to run' state and then depending upon the thread scheduler threads goes to the 'running' state and starts execution. Instead of this if we call run() method directly, then it goes to the 'running state' immediately and at that time if any thread is under execution, then it damage the total scheduled. Thats' why for thread execution we call start() method.

Mohanraj David said: (Sep 3, 2013)  
Good.

But one it start() methods only schedules the thread for execution and not actually begins the execution of the thread. The execution of the thread is started when the JVM calls the run () method of the thread once the CPU Scheduler picks this scheduled thread for execution.

Student said: (Jan 25, 2015)  
What is thread?

Vlstudent said: (Apr 23, 2015)  
Thread is piece of code that is running independently.

Vijay said: (Oct 12, 2017)  
Can we pass the parameter in start method?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.