Multithreading 1 quiz - Thread::run #42
-
|
For the Multithreading 1 quiz on Nov 8, it was mentioned that "We cannot call Thread::run but should call Thread::start. JVM will automatically call Thread::run after initializing the thread. We never call Thread::run ourselves" |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Thanks for your checking. You are right. The first answer has the similar effect as the last answer on the slide. If a thread's start method is not called, Java does not perform a context switching to a new call stack, and therefore the run method is run at the current call stack; in this example, it is the one used by the main thread. Without context switching to a new call stack, the effect is essentially like no new created thread. I have updated the finalreview slides at the course web page with additional comment for classmates' reference. In this examination, I will clarify the questions to minimize possible confusion. There will be a paper checking session after we have released the score, and classmates can appeal should we have missed correct answers in the grading. We will regrade a question for the whole class if we have made mistakes on it. Hope it clarifies. |
Beta Was this translation helpful? Give feedback.
Thanks for your checking. You are right. The first answer has the similar effect as the last answer on the slide. If a thread's start method is not called, Java does not perform a context switching to a new call stack, and therefore the run method is run at the current call stack; in this example, it is the one used by the main thread. Without context switching to a new call stack, the effect is essentially like no new created thread.
I have updated the finalreview slides at the course web page with additional comment for classmates' reference. In this examination, I will clarify the questions to minimize possible confusion. There will be a paper checking session after we have released th…