Eduardo Fierabras wrote:
Then, when the scheduler select the t thread to pass it from runnable to running, how is that the code executed is the statements following t.start();
I thought that when a thread goes into running state, the code in the run() method is executed. In this case the run() method is empty, or not?
Eduardo Fierabras wrote:
Perhaps the correct rule is the following: In the book example of code, the main thread creates a new thread (t), and t starts running the remaining code of the main() method.
And when t will terminate his job, the program will be finished, and the main thread that was executing the main() method is dead.
But what if the scheduler put thread t back to runnable before it has terminated his job? Then, the main thread can be put running again? And if so, at what point continues his job?
Eduardo Fierabras wrote:
Perhaps the correct rule is the following: In the book example of code, the main thread creates a new thread (t), and t starts running the remaining code of the main() method.
Eduardo Fierabras wrote:
And when t will terminate his job, the program will be finished, and the main thread that was executing the main() method is dead.
BEE MBA PMP SCJP-6
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
BEE MBA PMP SCJP-6
Henry Wong wrote:
Eduardo Fierabras wrote:
Then, when the scheduler select the t thread to pass it from runnable to running, how is that the code executed is the statements following t.start();
I thought that when a thread goes into running state, the code in the run() method is executed. In this case the run() method is empty, or not?
The default run() method is not exactly empty, but yea, it won't do anything noticeable. Just quickly do something and done -- pretty much as if the run() method was empty.
Henry
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
These are the worst of times and these are the best of times. And this is the best tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|