Hi guys,i have a qus,what do the start do(obj.start())? I will be grateful if you help me class Loader extends Thread { public void run() { System.out.println("Hello"); } } class MyClass { public static void main(String[ ] args) { Loader obj = new Loader(); obj.start(); } } | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi guys,i have a qus,what do the start do(obj.start())? I will be grateful if you help me class Loader extends Thread { public void run() { System.out.println("Hello"); } } class MyClass { public static void main(String[ ] args) { Loader obj = new Loader(); obj.start(); } }

18th Mar 2017, 12:42 PM
hurricane_jvd
hurricane_jvd - avatar
4 Answers
+ 2
using obj.run() would make the parent thread execute the function run(). using obj.start() would create a child and start the child execution at run()
18th Mar 2017, 1:01 PM
Bharath
Bharath - avatar
+ 1
creates a thread which starts execution at the function run()
18th Mar 2017, 12:53 PM
Bharath
Bharath - avatar
0
Thank you,but what is the diffrent between obj.start(); and obj.run(); ?
18th Mar 2017, 12:58 PM
hurricane_jvd
hurricane_jvd - avatar
0
You are a Genius dude,thanks✌️🙏
18th Mar 2017, 1:04 PM
hurricane_jvd
hurricane_jvd - avatar