0

Threads java help

can someone explain how does this thread code work?i cant understand the explanation in the sololearn lesson. https://code.sololearn.com/ci0n6OJsL2os/?ref=app

4th Nov 2017, 4:11 PM
oyl
4 Answers
+ 9
Since Loader class is extending Thread class, it'll inherit all properties of Thread class and will behave like a Thread. When we call start() method for a Thread object, it'll create a new thread and automatically call the run() method for the newly created object. run() : the existing thread runs šŸƒ start() : a new thread is born šŸ‘¶ and it runs šŸƒ So if you directly call the run() method without calling the start() method, it WON'T create a new thread, it'll just call run() for the CURRENT thread.
4th Nov 2017, 6:49 PM
Shamima Yasmin
Shamima Yasmin - avatar
+ 3
start() Causes this thread to begin execution; the Java Virtual Machine calls theĀ runĀ method of this thread.
4th Nov 2017, 6:10 PM
D_Stark
D_Stark - avatar
+ 1
aĀ threadĀ is a program's path of execution. Most programs written today run as a single thread, causing problems when multiple events or actions need to occur at the same time.Ā  The ideal solution to this problem is the seamless execution of two or more sections of a program at the same time. Threads allows us to do this.
5th Nov 2017, 4:14 AM
Talluri Saisumanth
Talluri Saisumanth - avatar
0
so when a class extends thread,this class becomes a new thread?so in the order for this new thread to execute run(),start() must be called?
4th Nov 2017, 6:32 PM
oyl