+ 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(); }}
3 odpowiedzi
+ 3
I mean to ask about the priority..in which order those methods works in thread execution..
+ 3
if I'm not wrong ..we use run() method in interfaces while start() to start a thread
+ 2
threads in parellel execution execute randomly..unless priority is set by using setPriority() method.