Which will contain the body of the thread? 1 point
a. run();
b. start();
c. stop();
d. main();?
Answers
Answered by
6
Hey there!
--------
Q. Which will contain the body of the thread?
(A) run() ✔
(B) start()
(C) stop()
(D) main()
Answer => Option (A) run()
--> The run() method contain the body of thread because the run() method to 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.
--------
Hope this helps :)
--------
Q. Which will contain the body of the thread?
(A) run() ✔
(B) start()
(C) stop()
(D) main()
Answer => Option (A) run()
--> The run() method contain the body of thread because the run() method to 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.
--------
Hope this helps :)
Answered by
0
(a). The run() method to a thread is like the main() method to an application.
Explanation:
- Starting the thread causes the object's run method to be called in that separately executing thread.
- If the thread was built using a separate Runnable object, the run() method of the Thread class is invoked.
- To start a thread, you must use the run method. To start a new thread, you must use the start method.
- If you call the run method directly, it will not start a separate thread and will remain on the same stack as the main thread.
- When a program calls the start() method, a new thread is created, and then the run() method is executed.
- But if we directly call the run() method then no new thread will be created and the run() method will be executed as a normal method call on the current calling thread itself and no multi-threading will take place.
Similar questions
Physics,
7 months ago
Science,
7 months ago
Math,
7 months ago
Computer Science,
1 year ago
Biology,
1 year ago
World Languages,
1 year ago