+ 4

I want to know more about run() and start() methods, how they work. I am confused.Can anybody help me?

class DrawImage extends Thread { public void run() { System.out.println("drawing image"); }} class PlayMusic extends Thread { public void run(){ System.out.println("playing music"); }} class MyGame{ public static void main(String[ ] args) { DrawImage diObj= new DrawImage(); diObj.start(); //diObj.run(); PlayMusic pmObj= new PlayMusic(); pmObj.start(); //pmObj.run(); }}

18th Jan 2018, 2:07 PM
Sunil Thakali
Sunil Thakali - avatar
3 Answers
+ 3
I mean to ask about the priority..in which order those methods works in thread execution..
18th Jan 2018, 2:10 PM
Sunil Thakali
Sunil Thakali - avatar
+ 3
if I'm not wrong ..we use run() method in interfaces while start() to start a thread
18th Jan 2018, 2:58 PM
Rishabh
Rishabh - avatar
+ 2
threads in parellel execution execute randomly..unless priority is set by using setPriority() method.
20th Jan 2018, 3:39 AM
Code Ninja
Code Ninja - avatar