I have a Class m2
which implements runnable and can be called with both run() and start() . Now i have read about “implements Runnable” vs. “extends Thread” , and what i'm asking here is
- start() vs run() for class m2
- how they compare with (as in when to use) an anonymous call like the one below.
public class test1{
public static void main(String[] args){
// m2
new m2().run();
new Thread( new m2()).start();
// anonymous
new Thread(new Runnable(){
public void run(){
System.out.println("anonymous code looks real cool!");
}
}).start();
}
}
class m2 implements Runnable{
public void run(){
System.out.println("hello from m2");
}
}
ps I'm putting in "multithreading" because i couldn't find a "thread" tag.