Java Programming - Threads - Discussion

Discussion Forum : Threads - General Questions (Q.No. 1)
1.
What is the name of the method used to start a thread execution?
init();
start();
run();
resume();
Answer: Option
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.

Discussion:
10 comments Page 1 of 1.

Shital Khairnar said:   2 years ago
@All.

The start() method will start the thread and the run() method will be used to implement the thread.
(2)

Vlstudent said:   10 years ago
Thread is piece of code that is running independently.
(1)

Srihari said:   6 years ago
Good explanation. Thanks all.
(1)

Srinu said:   1 decade ago
Good explanation.

Rajarajan said:   1 decade ago
Explain with any simple program.

Shakthi said:   1 decade ago
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:   1 decade ago
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:   1 decade ago
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:   1 decade ago
What is thread?

Vijay said:   7 years ago
Can we pass the parameter in start method?

Post your comments here:

Your comments will be displayed after verification.