Threads java help | Sololearn: Learn to code for FREE!


Threads java help

can someone explain how does this thread code work?i cant understand the explanation in the sololearn lesson.

11/4/2017 4:11:32 PM


4 Answers

New Answer


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.


start() Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.


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.


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?